1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/usr/bin/perl
#
# Written to suppliment crip with a Ogg Vorbis tag editor.
#
# Put preferred editor here
$editor = "vim";
$file = $ARGV[0];
use File::Temp;
(undef, $tmpfile) = File::Temp::tempfile(UNLINK => 1, OPEN => 0, SUFFIX => ".tag.tmp");
unless (-e "$file") {
die "File \"$file\" does not exist.\n";
}
unless ($file =~ m/\.ogg$/) {
die "File \"$file\" does not have the .ogg extension.\n";
}
# Escape certain characters from $file
# code taken directly from crip actually (crip does the same
# sort of thing 3 different times in its code)
# (don't ask me why it worked above but doesn't work below without escapes)
$file =~ s/\(/\\(/g; $file =~ s/\)/\\)/g;
$file =~ s/'/\\'/g; $file =~ s/`/\\`/g;
$file =~ s/\"/\\\"/g; $file =~ s/ /\\ /g;
system "vorbiscomment -l $file > $tmpfile";
system "$editor $tmpfile";
print "Writing new tag info...\n";
system "vorbiscomment -w -c $tmpfile $file";
print "Done.\n";
print "\nTag info now reads:\n";
system "vorbiscomment -l $file";
print "\n";
|