source: flacrip/trunk/mbz @ 31

Last change on this file since 31 was 31, checked in by peter, 9 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
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;
11use DiscFlacFile;
12
13GetOptions(
14    'flac=s' =>\my $FLAC_FILE,
15    'get-release-id' => \my $GET_RELEASE_ID,
16    'xml' =>\my $GET_XML,
17);
18
19my $discid;
20
21if ($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
28binmode STDOUT, ':utf8';
29
30# just dump the XML, if requested
31if ($GET_XML) {
32    print lookup_release($discid);
33    exit;
34}
35
36# otherwise, do the full parsing of the data
37my $info = get_musicbrainz_info($discid);
38
39exit unless $info;
40
41if ($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.