source: flacrip/trunk/cd2flac @ 36

Last change on this file since 36 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
Line 
1#!/usr/bin/perl -w
2use strict;
3
4use FindBin qw{$RealBin};
5use lib "$RealBin/lib";
6
7use Ripper;
8
9use File::Spec::Functions qw{catfile splitpath};
10use File::Path qw{mkpath};
11use Getopt::Long qw{:config no_ignore_case no_auto_abbrev};
12use Cwd;
13
14GetOptions(
15    'device|D=s' => \my $CD_DEVICE,
16    'output|o=s' => \my $OUTPUT_NAME,
17    'force|f'    => \my $FORCE,
18);
19
20# output file
21die "Usage: $0 -o <output.flac> [-D <device>]\n" unless $OUTPUT_NAME;
22my (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;
27mkpath($out_dir) unless -e $out_dir;
28my $archive_flac = catfile($out_dir, $out_file);
29
30# check for file exist; default to not overwrite
31die "$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
37my $ripper = Ripper->new({ device => $CD_DEVICE });
38$ripper->rip_to_flac($archive_flac);
39
40print "Rip saved as $archive_flac\n";
41system 'eject', $CD_DEVICE;
Note: See TracBrowser for help on using the repository browser.