Changeset 13 in flacrip for trunk


Ignore:
Timestamp:
05/15/14 21:11:52 (11 years ago)
Author:
peter
Message:
  • if there is a properties file with the same base name as the flac file, use it as the source of metadata info instead of doing a lookup to the MusicBrainz web service
  • don't rely on the TRACKS array key of $info to be present, since it is not there when reading from a properties file
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/flactrack

    r12 r13  
    3737my $info; 
    3838if ($ALL || $TYPE eq 'mp3') { 
    39     my $discid = $flac->tags('MBZ_DISCID') or warn "No MBZ_DISCID tag in $FLAC_FILE\n" if $flac; 
    40     #TODO: calculate TOC and DISCID from cuesheet if there is no MBZ_DISCID tag present 
     39    (my $properties_file = $FLAC_FILE) =~ s/\.flac$/.properties/; 
     40    if (-e $properties_file) { 
     41        require Config::Properties; 
    4142 
    42     $info = get_musicbrainz_info($discid); 
     43        my $properties = Config::Properties->new(file => $properties_file); 
     44        $info = $properties->getProperties; 
     45    } else { 
     46 
     47        my $discid = $flac->tags('MBZ_DISCID') or warn "No MBZ_DISCID tag in $FLAC_FILE\n" if $flac; 
     48        #TODO: calculate TOC and DISCID from cuesheet if there is no MBZ_DISCID tag present 
     49 
     50        $info = get_musicbrainz_info($discid); 
     51    } 
    4352    exit unless $info; 
    4453 
     
    6372    #TODO: default to just 01, 02, etc. if there is no $info 
    6473    %TRACKS = map { 
    65         $_ => catfile($DIRECTORY, sprintf('%02d.%s', $_, to_filename($info->{TRACKS}[$_]{TITLE}))) 
     74        $_ => catfile($DIRECTORY, sprintf('%02d.%s', $_, to_filename($info->{sprintf 'TRACK%02d.TITLE', $_}))) 
    6675    } (1 .. $count); 
    6776    #print Dump(\%TRACKS); 
     
    93102        # if there is track info, add it as ID3 tags 
    94103        if ($info) { 
    95             my $track = $info->{TRACKS}[$tracknum]; 
     104            my $track_key = sprintf 'TRACK%02d', $tracknum; 
    96105            $cmd .= sprintf q{ --tt %s --ta %s --tl %s --tn %d}, 
    97                 quote($track->{TITLE}), 
    98                 quote($track->{ARTIST}), 
     106                quote($info->{"$track_key.TITLE"}), 
     107                quote($info->{"$track_key.ARTIST"}), 
    99108                quote($info->{ALBUM}), 
    100109                $tracknum; 
Note: See TracChangeset for help on using the changeset viewer.