Changeset 41 in flacrip for trunk/lib


Ignore:
Timestamp:
05/08/15 20:00:01 (9 years ago)
Author:
peter
Message:

Use Audio::FLAC::Header to write the tags to the FLAC file instead of making
external calls to metaflac. In addition, rip_to_flac now returns a
DiscFlacFile object.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Ripper.pm

    r29 r41  
    44 
    55use Tracks; 
     6use DiscFlacFile; 
    67 
    78use File::Temp qw{tempdir}; 
     
    2021 
    2122sub rip_to_flac { 
    22     my ($self, $archive_flac) = @_; 
     23    my ($self, $archive_flac, $tags) = @_; 
    2324 
    2425    $self->tracks(Tracks->new); 
     
    5051    # copy to permanent location 
    5152    copy($flac_file, $archive_flac); 
    52     system 'metaflac', '--set-tag', "MUSICBRAINZ_DISCID=$discid", $archive_flac; 
     53 
     54    # tag the archive flac 
     55    $tags ||= {}; 
     56    $tags->{MUSICBRAINZ_DISCID} = $discid; 
     57    my $flac_disc = DiscFlacFile->new({ file => $archive_flac }); 
     58    $flac_disc->flac->{tags}{$_} = $tags->{$_} foreach keys %{$tags}; 
     59    $flac_disc->flac->write; 
     60 
     61    return $flac_disc; 
    5362} 
    5463 
Note: See TracChangeset for help on using the changeset viewer.