Last change
on this file since 35 was
23,
checked in by peter, 10 years ago
|
moved the code to do the ripping and converting to FLAC from cd2flac into a separate Ripper module
|
-
Property svn:executable set to
*
|
File size:
1.1 KB
|
Rev | Line | |
---|
[1] | 1 | #!/usr/bin/perl -w |
---|
| 2 | use strict; |
---|
| 3 | |
---|
[22] | 4 | use FindBin qw{$RealBin}; |
---|
| 5 | use lib "$RealBin/lib"; |
---|
[1] | 6 | |
---|
[23] | 7 | use Ripper; |
---|
[1] | 8 | |
---|
| 9 | use File::Spec::Functions qw{catfile splitpath}; |
---|
| 10 | use File::Path qw{mkpath}; |
---|
| 11 | use Getopt::Long qw{:config no_ignore_case no_auto_abbrev}; |
---|
| 12 | use Cwd; |
---|
| 13 | |
---|
| 14 | GetOptions( |
---|
| 15 | 'device|D=s' => \my $CD_DEVICE, |
---|
| 16 | 'output|o=s' => \my $OUTPUT_NAME, |
---|
| 17 | 'force|f' => \my $FORCE, |
---|
| 18 | ); |
---|
| 19 | |
---|
| 20 | # output file |
---|
[23] | 21 | die "Usage: $0 -o <output.flac> [-D <device>]\n" unless $OUTPUT_NAME; |
---|
[1] | 22 | my (undef, $out_dir, $out_file) = splitpath($OUTPUT_NAME); |
---|
| 23 | # automatically add ".flac" |
---|
| 24 | $out_file .= '.flac' unless $out_file =~ /\.flac$/; |
---|
| 25 | # default to current directory |
---|
| 26 | $out_dir ||= getcwd; |
---|
| 27 | mkpath($out_dir) unless -e $out_dir; |
---|
| 28 | my $archive_flac = catfile($out_dir, $out_file); |
---|
| 29 | |
---|
| 30 | # check for file exist; default to not overwrite |
---|
| 31 | die "$archive_flac exists\nwill not overwrite (use --force to override this)\n" |
---|
| 32 | if -e $archive_flac && !$FORCE; |
---|
| 33 | |
---|
| 34 | # get the CD info |
---|
| 35 | $CD_DEVICE ||= '/dev/cdrom'; |
---|
| 36 | |
---|
[23] | 37 | my $ripper = Ripper->new({ device => $CD_DEVICE }); |
---|
| 38 | $ripper->rip_to_flac($archive_flac); |
---|
[1] | 39 | |
---|
| 40 | print "Rip saved as $archive_flac\n"; |
---|
| 41 | system 'eject', $CD_DEVICE; |
---|
Note: See
TracBrowser
for help on using the repository browser.