Changeset 5 in flacrip


Ignore:
Timestamp:
05/06/13 15:47:48 (12 years ago)
Author:
peter
Message:
  • 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
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MusicBrainz.pm

    r4 r5  
    5353    # TODO: get release date 
    5454 
     55    # select the proper medium (important for multidisc releases) 
     56    my ($medium) = $xpath->findnodes("medium-list/medium[disc-list/disc/\@id='$discid']", $release); 
     57 
    5558    my $ua = LWP::UserAgent->new; 
    5659    my $tracknum = 1; 
    57     for my $track_node ($xpath->findnodes('.//track-list/track', $release)) { 
     60    for my $track_node ($xpath->findnodes('track-list/track', $medium)) { 
    5861        my $prefix = sprintf('TRACK%02d', $tracknum); 
    5962        #$info{"$prefix.MB_TRACKID"} = $xpath->findvalue('@id', $track_node); 
  • trunk/flactrack

    r4 r5  
    1111use File::Path; 
    1212use Audio::FLAC::Header; 
     13#TODO: put the MusicBrainz lib in a more common location 
     14use lib qw{/home/peter/projects/flacrip}; 
    1315use MusicBrainz; 
    1416 
     
    4345if ($ALL) { 
    4446    die "Use of --all requires a --directory\n" unless $DIRECTORY; 
     47    die "No track info found on MusicBrainz for $FLAC_FILE\n" unless $info; 
    4548    use YAML; 
    4649    my $cuesheet = $flac->cuesheet; 
     
    5154        $_ => catfile($DIRECTORY, sprintf('%02d.%s', $_, to_filename($info->{TRACKS}[$_]{TITLE}))) 
    5255    } (1 .. $count); 
    53     print Dump(\%TRACKS); 
     56    #print Dump(\%TRACKS); 
     57    for my $tracknum (sort { $a <=> $b } keys %TRACKS) { 
     58        printf "%2d: %s\n", $tracknum, $TRACKS{$tracknum}; 
     59    } 
    5460    mkpath($DIRECTORY); 
    5561} 
    5662 
    57 while (my ($tracknum, $title) = each %TRACKS) { 
     63#TODO: all the option of sorting by tracknum or not 
     64#while (my ($tracknum, $title) = each %TRACKS) { 
     65for my $tracknum (sort { $a <=> $b } keys %TRACKS) { 
    5866    if ($tracknum !~ /^\d+$/) { 
    5967        warn "Don't know what to do with track number '$tracknum'"; 
     
    6876    } 
    6977 
    70     $title = quotemeta($title); 
     78    my $title = quotemeta($TRACKS{$tracknum}); 
    7179    if ($TYPE eq 'mp3') { 
    7280        # bitrate of 192 
     
    8997    #die $cmd; 
    9098    system $cmd; 
     99    die "\nFLAC decoding canceled\n" if ($? & 127); 
    91100 
    92101    print "\n" if $SOX_FILTER; 
  • trunk/mbz

    r3 r5  
    4141} else { 
    4242    for my $key (sort keys %{ $info }) { 
    43         print "$key=$$info{$key}\n"; 
     43        print "$key=$$info{$key}\n" unless ref $info->{$key}; 
    4444    } 
    4545} 
  • trunk/use-cases

    r1 r5  
    1919 
    2020re-encode a mix as an archived flac for quick burning later 
     21 
     22submit a CD TOC to MusicBrainz 
     23    => submiturl 
     24    => metaflac --extract-cuesheet-to - | cuesheet2tocdata 
Note: See TracChangeset for help on using the changeset viewer.