source: flacrip/trunk/mbz @ 29

Last change on this file since 29 was 17, checked in by peter, 10 years ago

changed MBZ_DISCID to MUSICBRAINZ_DISCID, to match the standard MusicBrainz-Vorbis tag mappings

  • Property svn:executable set to *
File size: 1.1 KB
Line 
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
6use FindBin;
7use lib "$FindBin::RealBin/lib";
8
9use Getopt::Long;
10use MusicBrainz;
11
12GetOptions(
13    'flac=s' =>\my $FLAC_FILE,
14    'get-release-id' => \my $GET_RELEASE_ID,
15    'xml' =>\my $GET_XML,
16);
17
18my $discid;
19
20if ($FLAC_FILE) {
21    require Audio::FLAC::Header;
22    my $flac = Audio::FLAC::Header->new($FLAC_FILE) or die "Can't read FLAC header from $FLAC_FILE\n";
23    $discid = $flac->tags('MUSICBRAINZ_DISCID') or die "No MUSICBRAINZ_DISCID tag in $FLAC_FILE\n";
24} else {
25    $discid = shift;
26}
27
28# make the output terminal handle UTF-8 characters
29binmode STDOUT, ':utf8';
30
31# just dump the XML, if requested
32if ($GET_XML) {
33    print lookup_release($discid);
34    exit;
35}
36
37# otherwise, do the full parsing of the data
38my $info = get_musicbrainz_info($discid);
39
40exit unless $info;
41
42if ($GET_RELEASE_ID) {
43    print "$$info{MUSICBRAINZ_ALBUMID}\n";
44} else {
45    for my $key (sort keys %{ $info }) {
46        print "$key=$$info{$key}\n" unless ref $info->{$key};
47    }
48}
Note: See TracBrowser for help on using the repository browser.