summaryrefslogtreecommitdiffstats
path: root/tools/songdb.pl
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-06-07 12:22:52 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-06-07 12:22:52 +0000
commit4fb816df85cfbee060bae08042181d5f3654facc (patch)
tree022bb29ba94c99cc75ed4c9826e586a404616213 /tools/songdb.pl
parent82c2927d1e8e900bee29c73f066e341cf4ec0ea5 (diff)
downloadrockbox-4fb816df85cfbee060bae08042181d5f3654facc.tar.gz
rockbox-4fb816df85cfbee060bae08042181d5f3654facc.tar.bz2
rockbox-4fb816df85cfbee060bae08042181d5f3654facc.zip
Initial Vorbis Comments support. We just need a few more translations and it
should work fine. I personally don't have much "tagged" Vorbis songs so I'm not really the man to do this. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6592 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/songdb.pl')
-rwxr-xr-xtools/songdb.pl49
1 files changed, 40 insertions, 9 deletions
diff --git a/tools/songdb.pl b/tools/songdb.pl
index b2e248c898..9ed0c541bf 100755
--- a/tools/songdb.pl
+++ b/tools/songdb.pl
@@ -7,6 +7,8 @@
# it runnable standalone on removable drives. See below.
#
+use vorbiscomm;
+
my $db = "rockbox.id3db";
my $dir;
my $strip;
@@ -76,6 +78,36 @@ if(! -d $dir or $help) {
exit;
}
+sub get_oggtag {
+ my $fn = shift;
+ my %hash;
+
+ my $ogg = vorbiscomm->new($fn);
+
+ $ogg->load;
+
+ # Convert this format into the same format used by the id3 parser hash
+
+ foreach my $k ($ogg->comment_tags())
+ {
+ foreach my $cmmt ($ogg->comment($k))
+ {
+ my $n;
+ if($k =~ /^artist$/i) {
+ $n = 'ARTIST';
+ }
+ elsif($k =~ /^album$/i) {
+ $n = 'ALBUM';
+ }
+ $hash{$n}=$cmmt if($n);
+ # print $k, '=', $cmmt, "\n";
+ }
+ }
+
+ return \%hash;
+}
+
+
# return ALL directory entries in the given dir
sub getdir {
my ($dir) = @_;
@@ -83,7 +115,6 @@ sub getdir {
$dir =~ s|/$|| if ($dir ne "/");
if (opendir(DIR, $dir)) {
- # my @mp3 = grep { /\.mp3$/ && -f "$dir/$_" } readdir(DIR);
my @all = readdir(DIR);
closedir DIR;
return @all;
@@ -97,7 +128,7 @@ sub extractmp3 {
my ($dir, @files) = @_;
my @mp3;
for(@files) {
- if( /\.mp[23]$/ && -f "$dir/$_" ) {
+ if( (/\.mp[23]$/i || /\.ogg$/i) && -f "$dir/$_" ) {
push @mp3, $_;
}
}
@@ -118,15 +149,15 @@ sub extractdirs {
sub singlefile {
my ($file) = @_;
+ my $hash;
-# print "Check $file\n";
-
- my $hash = get_mp3tag($file);
- # my $hash = get_mp3info($file);
+ if($file =~ /\.ogg$/i) {
+ $hash = get_oggtag($file);
+ }
+ else {
+ $hash = get_mp3tag($file);
+ }
-# for(keys %$hash) {
-# print "Info: $_ ".$hash->{$_}."\n";
-# }
return $hash; # a hash reference
}