Last change
on this file since 34 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
|
Rev | Line | |
---|
[1] | 1 | #!/usr/bin/perl -w |
---|
| 2 | use 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] | 6 | use FindBin; |
---|
| 7 | use lib "$FindBin::RealBin/lib"; |
---|
| 8 | |
---|
[1] | 9 | use Getopt::Long; |
---|
[3] | 10 | use MusicBrainz; |
---|
[31] | 11 | use DiscFlacFile; |
---|
[1] | 12 | |
---|
| 13 | GetOptions( |
---|
| 14 | 'flac=s' =>\my $FLAC_FILE, |
---|
| 15 | 'get-release-id' => \my $GET_RELEASE_ID, |
---|
| 16 | 'xml' =>\my $GET_XML, |
---|
| 17 | ); |
---|
| 18 | |
---|
| 19 | my $discid; |
---|
| 20 | |
---|
| 21 | if ($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 |
---|
| 28 | binmode STDOUT, ':utf8'; |
---|
| 29 | |
---|
[3] | 30 | # just dump the XML, if requested |
---|
| 31 | if ($GET_XML) { |
---|
| 32 | print lookup_release($discid); |
---|
| 33 | exit; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | # otherwise, do the full parsing of the data |
---|
[1] | 37 | my $info = get_musicbrainz_info($discid); |
---|
| 38 | |
---|
| 39 | exit unless $info; |
---|
| 40 | |
---|
| 41 | if ($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.