source: flacrip/trunk/mbz @ 47

Last change on this file since 47 was 40, checked in by peter, 10 years ago

If given a barcode, get_musicbrainz_info() will attempt to match a release on
the DiscID and the barcode.

  • get_musicbrainz_info() and select_release() take a hashref with discid and barcode keys
  • mbz script takes a --barcode argument; however, if --flac is given, it dtermines the barcode from the BARCODE tag in the FLAC file
  • added a barcode method to the DiscFlacFile class
  • corrected the call to Audio::FLAC::Header::info to a call to tags for the Vorbis tags
  • removed the superfluous getprops script
  • Property svn:executable set to *
File size: 1.1 KB
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(
[40]14    'flac=s'         => \my $FLAC_FILE,
15    'barcode=s'      => \my $BARCODE,
[1]16    'get-release-id' => \my $GET_RELEASE_ID,
[40]17    'xml'            => \my $GET_XML,
[1]18);
19
20my $discid;
[40]21my $barcode;
[1]22
23if ($FLAC_FILE) {
[40]24    my $flac_disc = DiscFlacFile->new({ file => $FLAC_FILE });
25    $discid  = $flac_disc->discid;
26    $barcode = $flac_disc->barcode;
[1]27} else {
[40]28    $discid  = shift;
29    $barcode = $BARCODE;
[1]30}
31
32# make the output terminal handle UTF-8 characters
33binmode STDOUT, ':utf8';
34
[3]35# just dump the XML, if requested
36if ($GET_XML) {
37    print lookup_release($discid);
38    exit;
39}
40
41# otherwise, do the full parsing of the data
[40]42my $info = get_musicbrainz_info({
43    discid  => $discid,
44    barcode => $barcode,
45});
[1]46
47exit unless $info;
48
49if ($GET_RELEASE_ID) {
[8]50    print "$$info{MUSICBRAINZ_ALBUMID}\n";
[1]51} else {
52    for my $key (sort keys %{ $info }) {
[31]53        print "$key=$$info{$key}\n";
[1]54    }
55}
Note: See TracBrowser for help on using the repository browser.