Added -T option for cdripper and tagfromfilename.
This commit is contained in:
parent
d8aa8d9856
commit
d629c49b49
9
cdripper
9
cdripper
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# CD Ripper
|
||||
# usage: cdripper [-o num] [--no-cddb] [-a] [-y] [target_directory]
|
||||
# usage: cdripper [-o num] [--no-cddb] [-T] [-a] [-y] [target_directory]
|
||||
#
|
||||
# Rips the contents of an audio CD into Ogg Vorbis files
|
||||
# Puts the files in target_directory/artist/album_name/
|
||||
|
@ -11,6 +11,7 @@
|
|||
#
|
||||
# Changelog:
|
||||
# 0.2.4: Fixed bug - files should get tagged again
|
||||
# Added support for -T option
|
||||
# 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
|
||||
|
@ -39,7 +40,8 @@ $HELP_MSG = "# CD Ripper v$VERSION\n\tusage: cdripper [--no-cddb] [-a] " .
|
|||
"Options:\n-a:\t\tAsk users about multiple CDDB options\n" .
|
||||
"-o [num]:\tOffset track numbers by num. The first track will be num+1\n" .
|
||||
"-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";
|
||||
"--no-cddb:\tDon't use CDDB. Prompt the user for all information.\n" .
|
||||
"-T:\t\tWrite uppercase tag names. Passes -T to tagfromfilename";
|
||||
|
||||
$CDPARANOIA_FORMAT = 'track*.cdda';
|
||||
$TRACK_ZERO = 'track00';
|
||||
|
@ -65,6 +67,7 @@ foreach (@ARGV)
|
|||
elsif (/^--no-cddb$/) { $useCDDB = 0; }
|
||||
elsif (/^-f$/) { $noInput = 1; }
|
||||
elsif (/^-a$/) { $askCDDB = 1; }
|
||||
elsif (/^-T$/) { $uppertags = '-T'; }
|
||||
else
|
||||
{
|
||||
$target_directory = $_;
|
||||
|
@ -101,7 +104,7 @@ chdir($final_location);
|
|||
warn "Some files were not automatically named." if $unhandledFiles;
|
||||
|
||||
# Add vorbiscomment data
|
||||
system('tagfromfilename', @new_tracks);
|
||||
system('tagfromfilename', $uppertags, @new_tracks);
|
||||
|
||||
# Clean up
|
||||
chdir($orig_dir);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# options:
|
||||
# -n: Only set the track number
|
||||
# -0: Leading 0s in track number are preserved
|
||||
# -T: Tag names (not tag content) written to the metadata in all caps
|
||||
#
|
||||
# Adds Vorbiscomment data to ogg vorbis and flac files based on the filename.
|
||||
# Files should be in Patrick's arbitrary file name standard, which is:
|
||||
|
@ -17,6 +18,7 @@
|
|||
# Requires vorbiscomment and metaflac
|
||||
#
|
||||
# Changelog:
|
||||
# 0.2.4: added -T option
|
||||
# 0.2.3: added documentation, -0 command-line option
|
||||
# 0.2.2: added flac support, documentation
|
||||
# 0.2.1: fixed version in help message
|
||||
|
@ -25,8 +27,8 @@
|
|||
# 0.1.1: added version variable
|
||||
# 0.1: initial implementation
|
||||
|
||||
$VERSION = "0.2.3";
|
||||
$HELP_MSG = "Vorbiscomment from Filename $VERSION\n\tusage: vcfromfilename [options] <files>\n\nValid options:\n\t-n\tOnly set the track numbers\n\t-0\tPreserve leading 0s in track numbers";
|
||||
$VERSION = "0.2.4";
|
||||
$HELP_MSG = "Vorbiscomment from Filename $VERSION\n\tusage: vcfromfilename [options] <files>\n\nValid options:\n\t-n\tOnly set the track numbers\n\t-0\tPreserve leading 0s in track numbers\n\t-T: Write tag names (not tag content) in all caps";
|
||||
|
||||
chomp($COMMENTFILENAME = '/tmp/vcfromfilename-' . `whoami`);
|
||||
|
||||
|
@ -34,14 +36,15 @@ chomp($COMMENTFILENAME = '/tmp/vcfromfilename-' . `whoami`);
|
|||
foreach (@ARGV)
|
||||
{
|
||||
if (/^(-h)|(--help)$/) { die $HELP_MSG; }
|
||||
if (/^-n$/) { $tracknumonly = true; s/.*//g; }
|
||||
if (/^-0$/) { $extrazero = true; s/.*//g; }
|
||||
elsif (/^-n$/) { $tracknumonly = true; s/.*//g; }
|
||||
elsif (/^-T$/) { $captagnames = true; s/.*//g; }
|
||||
elsif (/^-0$/) { $extrazero = true; s/.*//g; }
|
||||
}
|
||||
|
||||
# Set the album name
|
||||
$album = `pwd`; # We WANT the newline here
|
||||
$album =~ s/^.*\///; # Remove everything up to the last /
|
||||
$album = formatName($album, 'album=');
|
||||
$album = formatName($album, 'album=', $captagnames);
|
||||
|
||||
# Parse the file list, set vorbiscomments
|
||||
foreach (@ARGV)
|
||||
|
@ -79,13 +82,13 @@ foreach (@ARGV)
|
|||
# Add the artist
|
||||
my $artist = $_;
|
||||
$artist =~ s/^(.*?)-\d{2}-.*/\1/; # grab everything to the track number
|
||||
$artist = formatName($artist, 'artist=');
|
||||
$artist = formatName($artist, 'artist=', $captagnames);
|
||||
print COMMENTFILE $artist;
|
||||
|
||||
# Add the title
|
||||
my $title = $_;
|
||||
$title =~ s/.*-\d{2}-(.*)\.(ogg|flac)$/\1/; # grab everything after the track number
|
||||
$title = formatName($title, 'title=');
|
||||
$title = formatName($title, 'title=', $captagnames);
|
||||
print COMMENTFILE $title;
|
||||
|
||||
# And the album
|
||||
|
@ -96,7 +99,7 @@ foreach (@ARGV)
|
|||
my $tracknum = $_;
|
||||
$tracknum =~ s/.*-(\d{2})-.*/\1/;
|
||||
if (!$extrazeros) { $tracknum =~ s/\b0*//; } # removing leading zeros
|
||||
$tracknum = formatName($tracknum, 'tracknumber=');
|
||||
$tracknum = formatName($tracknum, 'tracknumber=', $captagnames);
|
||||
print COMMENTFILE $tracknum;
|
||||
|
||||
close COMMENTFILE;
|
||||
|
@ -107,10 +110,14 @@ foreach (@ARGV)
|
|||
}
|
||||
|
||||
# Formats the first argument, adds the second argument to it
|
||||
# If the third argument is true, the second argument is converted
|
||||
# to upper case
|
||||
sub formatName
|
||||
{
|
||||
my $name = shift;
|
||||
my $prepend = shift;
|
||||
my $upper = shift;
|
||||
if ($upper) { $prepend = uc($prepend); }
|
||||
chomp $name; # we add a newline ourselves
|
||||
$name =~ s/_/ /g; # underscore - space
|
||||
$name =~ s/^\s*//; # Remove leading space
|
||||
|
|
Reference in New Issue
Block a user