Changeset 42 in flacrip


Ignore:
Timestamp:
05/08/15 20:12:40 (7 years ago)
Author:
peter
Message:

issue #5: if the --properties flag is given to cd2flac, it will attempt to
automatically fetch the MusicBrainz metadata for the ripped CD and write it to
a properties file with the same name as the FLAC file, but with the
".properties" extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cd2flac

    r41 r42  
    1212use Cwd; 
    1313use Audio::FLAC::Header; 
     14use MusicBrainz; 
    1415 
    1516GetOptions( 
     
    1819    'force|f'     => \my $FORCE, 
    1920    'barcode|b=s' => \my $BARCODE, 
     21    'properties'  => \my $PROPERTIES, 
    2022); 
    2123 
     
    3941my $tags = $BARCODE ? { BARCODE => $BARCODE } : {}; 
    4042my $ripper = Ripper->new({ device => $CD_DEVICE }); 
    41 $ripper->rip_to_flac($archive_flac, $tags); 
     43my $flac_disc = $ripper->rip_to_flac($archive_flac, $tags); 
     44 
     45if ($PROPERTIES) { 
     46    my $info = get_musicbrainz_info({ 
     47        discid  => $flac_disc->discid, 
     48        barcode => $flac_disc->barcode, 
     49    }); 
     50    if ($info) { 
     51        (my $properties_file = $archive_flac) =~ s/\.flac$/.properties/; 
     52        open my $fh, '>', $properties_file or die "Cannot write $properties_file\n"; 
     53        print $fh "$_=$$info{$_}\n" foreach sort keys %{ $info }; 
     54        close $fh; 
     55        print "Properties written as $properties_file\n"; 
     56    } 
     57} 
    4258 
    4359print "Rip saved as $archive_flac\n"; 
Note: See TracChangeset for help on using the changeset viewer.