Changeset 23 in flacrip for trunk/cd2flac
- Timestamp:
- 10/08/14 21:24:21 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cd2flac
r22 r23 5 5 use lib "$RealBin/lib"; 6 6 7 use Tracks;7 use Ripper; 8 8 9 use File::Temp qw{tempdir};10 9 use File::Spec::Functions qw{catfile splitpath}; 11 use File::Copy;12 10 use File::Path qw{mkpath}; 13 11 use Getopt::Long qw{:config no_ignore_case no_auto_abbrev}; … … 20 18 ); 21 19 20 # output file 22 21 die "Usage: $0 -o <output.flac> [-D <device>]\n" unless $OUTPUT_NAME; 23 24 # output file25 22 my (undef, $out_dir, $out_file) = splitpath($OUTPUT_NAME); 26 23 # automatically add ".flac" … … 37 34 # get the CD info 38 35 $CD_DEVICE ||= '/dev/cdrom'; 39 my $tracks = Tracks->new;40 $tracks->read_disc($CD_DEVICE);41 36 42 die "No tracks found; is there a CD in the drive?\n" unless @{ $tracks->get_tracks }; 37 my $ripper = Ripper->new({ device => $CD_DEVICE }); 38 $ripper->rip_to_flac($archive_flac); 43 39 44 my $tempdir = tempdir(CLEANUP => 1);45 46 my $wav_file = catfile($tempdir, 'cdda.wav');47 my $flac_file = catfile($tempdir, 'cdda.flac');48 my $cue_file = catfile($tempdir, 'cdda.cue');49 50 # rip51 my $span = $tracks->get_cdparanoia_span;52 system 'cdparanoia', '-d', $CD_DEVICE, $span, $wav_file;53 die "\nRipping canceled\n" if ($? & 127);54 55 # encode + cuesheet56 open my $CUE, "> $cue_file";57 print $CUE $tracks->get_cuesheet;58 close $CUE;59 system 'flac', '-o', $flac_file, '--cuesheet', $cue_file, $wav_file;60 die "\nFLAC encoding canceled\n" if ($? & 127);61 62 # MusicBrainz discid metadata63 my $discid = $tracks->get_mbz_discid;64 65 # copy to permanent location66 copy($flac_file, $archive_flac);67 system 'metaflac', '--set-tag', "MUSICBRAINZ_DISCID=$discid", $archive_flac;68 40 print "Rip saved as $archive_flac\n"; 69 41 system 'eject', $CD_DEVICE;
Note: See TracChangeset
for help on using the changeset viewer.