Last change
on this file since 5 was
5,
checked in by peter, 12 years ago
|
- mbz: only print non-ref values of the info
- use-cases: added note about submitting a new discid
- flactrack:
- hardcoded the library location for now
- sort the supplied %TRACKS by their keys
- remove special characters from the output filename using quotemeta
- abort with an error message if no MusicBrainz info is found
- abort with an error message if the flac decoding is canceled
- MusicBrainz.pm: select the proper medium (by DiscID) as the context for querying the tracklist, so multi-disc releases get the proper tracklist
|
-
Property svn:executable set to
*
|
File size:
1.0 KB
|
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 Getopt::Long; |
---|
7 | use MusicBrainz; |
---|
8 | |
---|
9 | GetOptions( |
---|
10 | 'flac=s' =>\my $FLAC_FILE, |
---|
11 | 'get-release-id' => \my $GET_RELEASE_ID, |
---|
12 | 'xml' =>\my $GET_XML, |
---|
13 | ); |
---|
14 | |
---|
15 | my $discid; |
---|
16 | |
---|
17 | if ($FLAC_FILE) { |
---|
18 | require Audio::FLAC::Header; |
---|
19 | my $flac = Audio::FLAC::Header->new($FLAC_FILE) or die "Can't read FLAC header from $FLAC_FILE\n"; |
---|
20 | $discid = $flac->tags('MBZ_DISCID') or die "No MBZ_DISCID tag in $FLAC_FILE\n"; |
---|
21 | } else { |
---|
22 | $discid = shift; |
---|
23 | } |
---|
24 | |
---|
25 | # make the output terminal handle UTF-8 characters |
---|
26 | binmode STDOUT, ':utf8'; |
---|
27 | |
---|
28 | # just dump the XML, if requested |
---|
29 | if ($GET_XML) { |
---|
30 | print lookup_release($discid); |
---|
31 | exit; |
---|
32 | } |
---|
33 | |
---|
34 | # otherwise, do the full parsing of the data |
---|
35 | my $info = get_musicbrainz_info($discid); |
---|
36 | |
---|
37 | exit unless $info; |
---|
38 | |
---|
39 | if ($GET_RELEASE_ID) { |
---|
40 | print "$$info{RELEASE_MBID}\n"; |
---|
41 | } else { |
---|
42 | for my $key (sort keys %{ $info }) { |
---|
43 | print "$key=$$info{$key}\n" unless ref $info->{$key}; |
---|
44 | } |
---|
45 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.