source: flacrip/trunk/mbz @ 35

Last change on this file since 35 was 31, checked in by peter, 10 years ago
  • mbz uses DiscFlacFile to read the discid from a FLAC file
  • remove the TRACKS array from the returned info hash from get_musicbrainz_info()
  • Tracks::read_flac() can take an Audio::FLAC::Header as its argument instead of a filename
  • Property svn:executable set to *
File size: 929 bytes
RevLine 
[1]1#!/usr/bin/perl -w
2use strict;
3
4# one use case: for f in ~/cds/*.flac; do mbid=`./mbz --flac $f --get-release-id`; echo $f $mbid; done;
5
[11]6use FindBin;
7use lib "$FindBin::RealBin/lib";
8
[1]9use Getopt::Long;
[3]10use MusicBrainz;
[31]11use DiscFlacFile;
[1]12
13GetOptions(
14    'flac=s' =>\my $FLAC_FILE,
15    'get-release-id' => \my $GET_RELEASE_ID,
16    'xml' =>\my $GET_XML,
17);
18
19my $discid;
20
21if ($FLAC_FILE) {
[31]22    $discid = DiscFlacFile->new({ file => $FLAC_FILE })->discid;
[1]23} else {
24    $discid = shift;
25}
26
27# make the output terminal handle UTF-8 characters
28binmode STDOUT, ':utf8';
29
[3]30# just dump the XML, if requested
31if ($GET_XML) {
32    print lookup_release($discid);
33    exit;
34}
35
36# otherwise, do the full parsing of the data
[1]37my $info = get_musicbrainz_info($discid);
38
39exit unless $info;
40
41if ($GET_RELEASE_ID) {
[8]42    print "$$info{MUSICBRAINZ_ALBUMID}\n";
[1]43} else {
44    for my $key (sort keys %{ $info }) {
[31]45        print "$key=$$info{$key}\n";
[1]46    }
47}
Note: See TracBrowser for help on using the repository browser.