Changeset 10 in flacrip


Ignore:
Timestamp:
02/26/14 14:37:32 (10 years ago)
Author:
peter
Message:
  • if flactrack has the album metadata, generate a directory name using the album's original release date, to make the album directories sort chronologically within artists
  • convert "&" to " and " in name and title strings
  • MusicBrainz retrieves the disc number and total number of discs for multidisc releases
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MusicBrainz.pm

    r9 r10  
    7676    # select the proper medium (important for multidisc releases) 
    7777    my ($medium) = $xpath->findnodes("medium-list/medium[disc-list/disc/\@id='$discid']", $release); 
     78 
     79    # disc position info 
     80    $info{DISCNUMBER} = $xpath->findvalue('position', $medium)->value; 
     81    $info{DISCTOTAL}  = $xpath->findvalue('../@count', $medium)->value; 
    7882 
    7983    #my $ua = LWP::UserAgent->new; 
  • trunk/flactrack

    r5 r10  
    88 
    99use Getopt::Long qw{:config no_ignore_case}; 
    10 use File::Spec::Functions qw{catfile}; 
     10use File::Spec::Functions qw{catfile splitpath}; 
    1111use File::Path; 
    1212use Audio::FLAC::Header; 
     
    3939    #TODO: calculate TOC and DISCID from cuesheet if there is no MBZ_DISCID tag present 
    4040 
    41     #TODO: also get the year from MBZ 
    4241    $info = get_musicbrainz_info($discid); 
     42 
     43    # if we have metadata, change the directory name to ARTIST.DATE.ALBUM, so it will sort nicely 
     44    my $base_dir = (splitpath($DIRECTORY))[1]; 
     45    my $album_dir = join('.', map { to_filename($_) } @{$info}{qw{ALBUMARTISTSORT ORIGINALDATE ALBUM}}); 
     46    # need to append "disc#" if this is a multidisc album 
     47    if ($info->{DISCTOTAL} > 1) { 
     48        $album_dir .= '.disc_' . $info->{DISCNUMBER}; 
     49    } 
     50    $DIRECTORY = catfile($base_dir, $album_dir); 
     51    #die $DIRECTORY; 
    4352} 
    4453 
     
    112121    #TODO: deal with non-ascii characters (unidecode) e.g. ü --> ue 
    113122    return map { 
     123        s/&/ and /g; 
    114124        s/[^a-z0-9-_ ]+//gi; 
    115125        s/ +/_/g; 
Note: See TracChangeset for help on using the changeset viewer.