|
Last change
on this file since 31 was
31,
checked in by peter, 11 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
|
| Line | |
|---|
| 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 | |
|---|
| 6 | use FindBin; |
|---|
| 7 | use lib "$FindBin::RealBin/lib"; |
|---|
| 8 | |
|---|
| 9 | use Getopt::Long; |
|---|
| 10 | use MusicBrainz; |
|---|
| 11 | use DiscFlacFile; |
|---|
| 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) { |
|---|
| 22 | $discid = DiscFlacFile->new({ file => $FLAC_FILE })->discid; |
|---|
| 23 | } else { |
|---|
| 24 | $discid = shift; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | # make the output terminal handle UTF-8 characters |
|---|
| 28 | binmode STDOUT, ':utf8'; |
|---|
| 29 | |
|---|
| 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 |
|---|
| 37 | my $info = get_musicbrainz_info($discid); |
|---|
| 38 | |
|---|
| 39 | exit unless $info; |
|---|
| 40 | |
|---|
| 41 | if ($GET_RELEASE_ID) { |
|---|
| 42 | print "$$info{MUSICBRAINZ_ALBUMID}\n"; |
|---|
| 43 | } else { |
|---|
| 44 | for my $key (sort keys %{ $info }) { |
|---|
| 45 | print "$key=$$info{$key}\n"; |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.