Added flac options
This commit is contained in:
40
cdripper
40
cdripper
@ -13,6 +13,7 @@
|
||||
# 0.2.4: Fixed bug - files should get tagged again
|
||||
# Added support for -T option
|
||||
# Added support for -0 option
|
||||
# Added -q and -f options
|
||||
# 0.2: Aligned version with ds-audiotools
|
||||
# Implemented CDDB support (disabled with --no-cddb)
|
||||
# Ability to preview and edit all text before it's used
|
||||
@ -43,9 +44,12 @@ $HELP_MSG = "# CD Ripper v$VERSION\n\tusage: cdripper [--no-cddb] [-a] " .
|
||||
"-y:\t\tDon't prompt for user confirmation of CDDB information\n\t\t(assume defaults are okay).\n" .
|
||||
"--no-cddb:\tDon't use CDDB. Prompt the user for all information.\n" .
|
||||
"-T:\t\tWrite uppercase tag names. Passes -T to tagfromfilename\n" .
|
||||
"-q <number>:\tquality to encode the vorbis data. Defaults to 10. Unused in FLAC mode.\n" .
|
||||
"-f:\t\tencode to FLAC instead of vorbis\n" .
|
||||
"-0:\t\tPreserve leading 0 in track numbers\n";
|
||||
|
||||
$CDPARANOIA_FORMAT = 'track*.cdda';
|
||||
$quality = '7';
|
||||
$TRACK_ZERO = 'track00';
|
||||
chomp($orig_dir = `pwd`);
|
||||
chomp($temp_dir = '/tmp/ds-cdripper-' . `whoami`);
|
||||
@ -54,6 +58,7 @@ $offset = 0;
|
||||
$useCDDB = 1;
|
||||
$noInput = 0;
|
||||
$askCDDB = 0;
|
||||
$flac_mode = 0;
|
||||
|
||||
$tagoptions = '';
|
||||
|
||||
@ -64,13 +69,20 @@ foreach (@ARGV)
|
||||
$offset = $_;
|
||||
$offsetOnNext = 0;
|
||||
}
|
||||
elsif ($qualityOnNext)
|
||||
{
|
||||
$quality = $_;
|
||||
$qualityOnNext = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (/^(--help)|(-h)$/) { print $HELP_MSG; exit; }
|
||||
elsif (/^-o$/) { $offsetOnNext = 1; }
|
||||
elsif (/^--no-cddb$/) { $useCDDB = 0; }
|
||||
elsif (/^-f$/) { $noInput = 1; }
|
||||
elsif (/^-y$/) { $noInput = 1; }
|
||||
elsif (/^-a$/) { $askCDDB = 1; }
|
||||
elsif (/^-f$/) { $flac_mode = 1; }
|
||||
elsif (/^-q$/) { $qualityOnNext = 1; }
|
||||
elsif (/^-T$/) { $tagoptions .= ' -T'; }
|
||||
elsif (/^-0$/) { $tagoptions .= ' -0'; }
|
||||
else
|
||||
@ -80,6 +92,11 @@ foreach (@ARGV)
|
||||
}
|
||||
}
|
||||
|
||||
# Extension, for use in later commands
|
||||
if ($flac_mode) { $extension = 'flac'; }
|
||||
else { $extension = 'ogg'; }
|
||||
|
||||
|
||||
# Create temp location
|
||||
system("rm -rf $temp_dir 2> /dev/null");
|
||||
mkdir($temp_dir);
|
||||
@ -90,7 +107,14 @@ handle_names();
|
||||
|
||||
# Rip, convert
|
||||
system('cdparanoia -B');
|
||||
system("oggenc $CDPARANOIA_FORMAT.wav");
|
||||
if ($flac_mode)
|
||||
{
|
||||
system("flac $CDPARANOIA_FORMAT.wav");
|
||||
}
|
||||
else
|
||||
{
|
||||
system("oggenc -q $quality $CDPARANOIA_FORMAT.wav");
|
||||
}
|
||||
$sanityTest = `ls -1 | wc -l`;
|
||||
chomp $sanityTest;
|
||||
die "No files were created. Aborting." unless ($sanityTest > 0);
|
||||
@ -109,6 +133,10 @@ chdir($final_location);
|
||||
warn "Some files were not automatically named." if $unhandledFiles;
|
||||
|
||||
# Add vorbiscomment data
|
||||
#debug
|
||||
print `pwd`;
|
||||
print `ls`;
|
||||
#end debug
|
||||
system('tagfromfilename', $tagoptions, @new_tracks);
|
||||
|
||||
# Clean up
|
||||
@ -147,8 +175,8 @@ sub getinfo_user
|
||||
chomp (my $input = <STDIN>);
|
||||
my $input = `fixname -o "$input"`;
|
||||
|
||||
my $track_name = $artist . '-' . $current_track . '-' . $input .
|
||||
'.ogg';
|
||||
my $track_name = $artist . '-' . $current_track . '-' . $input . '.' .
|
||||
$extension;
|
||||
|
||||
push @new_tracks, $track_name;
|
||||
$current_track++;
|
||||
@ -176,7 +204,7 @@ sub getinfo_cddb
|
||||
foreach (@{$cd{track}})
|
||||
{
|
||||
my $track_name = $artist . '-' . $current_track . '-' .
|
||||
`fixname -o "$_"` . '.ogg';
|
||||
`fixname -o "$_"` . '.' . $extension;
|
||||
|
||||
push @new_tracks, $track_name;
|
||||
$current_track++;
|
||||
@ -211,7 +239,7 @@ sub init_current_track
|
||||
# Populates the @old_tracks array
|
||||
sub init_old_tracks
|
||||
{
|
||||
foreach (`ls $CDPARANOIA_FORMAT.ogg`)
|
||||
foreach (`ls $CDPARANOIA_FORMAT.$extension`)
|
||||
{
|
||||
chomp;
|
||||
next if /$TRACK_ZERO/;
|
||||
|
Reference in New Issue
Block a user