[vorbis-dev] using vorbiscomment
Alex Shinn
foof at debian.org
Sun Oct 15 10:17:01 PDT 2000
As far as I could find, nowhere in the documentation or even source
does it actually explain how to use vorbiscomment. Just a simple
"vorbiscomment reads TAG=VALUE pairs on separate lines from stdin"
would save people a lot of time. Of course, this is still a painful
tool to use, and since I had some .ogg's lying around with broken
comments (from my first ogg vorbis patch to grip), I wrote a little
Perl script (attached) to behave like mp3info. It has short and long
command options for all of the suggested vorbis comment fields, and
can act on multiple files listed on the command line.
BTW, is anyone working on a vorbis Perl module? If not, I'll probably
put one together.
--
Alex
#!/usr/bin/perl -w
## ogginfo -- Ogg Vorbis Comment Editor
## Created: <Sun Oct 15 02:57:05 EDT 2000>
## Time-stamp: <Sun Oct 15 12:44:08 EDT 2000>
## Author: Alex Shinn <foof at debian.org>
# Modules
use strict;
use Getopt::Long;
# Variables
my $version = '0.1';
my %opt;
my %old;
my %new;
# Parse Options
GetOptions(\%opt, 'h!','help!','V!','ogg-version!','t:s','title:s',
'v:s','version:s','l:s','album:s','a:s','artist:s',
'o:s','organization:s','D:s','description:s','g:s','genre:s',
'd:s','date:s','p:s','location:s','c:s','copyright:s')
or usage();
usage() if $opt{h} || $opt{help};
version() if $opt{V} || $opt{'ogg-version'};
# Translate short options
$opt{title} = $opt{t} if exists $opt{t};
$opt{version} = $opt{v} if exists $opt{v};
$opt{album} = $opt{l} if exists $opt{l};
$opt{artist} = $opt{a} if exists $opt{a};
$opt{organization} = $opt{o} if exists $opt{o};
$opt{description} = $opt{D} if exists $opt{D};
$opt{genre} = $opt{g} if exists $opt{g};
$opt{date} = $opt{d} if exists $opt{d};
$opt{location} = $opt{p} if exists $opt{p};
$opt{copyright} = $opt{c} if exists $opt{c};
# Read comment options
$new{title} = $opt{title} if exists $opt{title};
$new{version} = $opt{version} if exists $opt{version};
$new{album} = $opt{album} if exists $opt{album};
$new{artist} = $opt{artist} if exists $opt{artist};
$new{organization} = $opt{organization} if exists $opt{organization};
$new{description} = $opt{description} if exists $opt{description};
$new{genre} = $opt{genre} if exists $opt{genre};
$new{date} = $opt{date} if exists $opt{date};
$new{location} = $opt{location} if exists $opt{location};
$new{copyright} = $opt{copyright} if exists $opt{copyright};
# Act on each remaining arg
foreach my $ogg (@ARGV) {
# Get existing comments
%old = map { my ($tag, $value) = split(/=/,$_,2); chop($value);
"\L$tag", $value }
`vorbiscomment -l $ogg 2>/dev/null`;
next if $?;
# Merge new comments
while (my ($k, $v) = each(%new)) {
$old{$k} = $v;
}
if (%new) {
# Set new comments
open(OUTPUT, "| vorbiscomment $ogg 2>/dev/null") || next;
while (my ($k, $v) = each(%old)) {
if ($v) {
print OUTPUT "\U$k", "=$v\n";
}
}
close(OUTPUT);
}
else {
while (my ($k, $v) = each(%old)) {
print "\U$k", "=$v\n";
}
}
}
# Print a usage summary
sub usage {
print <<EOF;
usage: $0 [options] [file ...]
-h, --help display this message
-V, --ogg-version print version info
-t, --title=TITLE set title
-v, --version=VER set title version
-l, --album=ALBUM set album
-a, --artist=artist set artist
-o, --organization=ORG set organization/record label
-D, --description=DESC set brief contents description
-g, --genre=GENRE set short genre description
-d, --date=DATE set date
-p, --location=PLACE set recording location info
-c, --copyright=COPY set copyright info
EOF
exit 0;
}
# Print version info
sub version {
print "$0 $version\n";
exit 0;
}
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev
mailing list