summaryrefslogtreecommitdiff
path: root/tools/songdb.pl
diff options
context:
space:
mode:
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 @@
7# it runnable standalone on removable drives. See below. 7# it runnable standalone on removable drives. See below.
8# 8#
9 9
10use vorbiscomm;
11
10my $db = "rockbox.id3db"; 12my $db = "rockbox.id3db";
11my $dir; 13my $dir;
12my $strip; 14my $strip;
@@ -76,6 +78,36 @@ if(! -d $dir or $help) {
76 exit; 78 exit;
77} 79}
78 80
81sub get_oggtag {
82 my $fn = shift;
83 my %hash;
84
85 my $ogg = vorbiscomm->new($fn);
86
87 $ogg->load;
88
89 # Convert this format into the same format used by the id3 parser hash
90
91 foreach my $k ($ogg->comment_tags())
92 {
93 foreach my $cmmt ($ogg->comment($k))
94 {
95 my $n;
96 if($k =~ /^artist$/i) {
97 $n = 'ARTIST';
98 }
99 elsif($k =~ /^album$/i) {
100 $n = 'ALBUM';
101 }
102 $hash{$n}=$cmmt if($n);
103 # print $k, '=', $cmmt, "\n";
104 }
105 }
106
107 return \%hash;
108}
109
110
79# return ALL directory entries in the given dir 111# return ALL directory entries in the given dir
80sub getdir { 112sub getdir {
81 my ($dir) = @_; 113 my ($dir) = @_;
@@ -83,7 +115,6 @@ sub getdir {
83 $dir =~ s|/$|| if ($dir ne "/"); 115 $dir =~ s|/$|| if ($dir ne "/");
84 116
85 if (opendir(DIR, $dir)) { 117 if (opendir(DIR, $dir)) {
86 # my @mp3 = grep { /\.mp3$/ && -f "$dir/$_" } readdir(DIR);
87 my @all = readdir(DIR); 118 my @all = readdir(DIR);
88 closedir DIR; 119 closedir DIR;
89 return @all; 120 return @all;
@@ -97,7 +128,7 @@ sub extractmp3 {
97 my ($dir, @files) = @_; 128 my ($dir, @files) = @_;
98 my @mp3; 129 my @mp3;
99 for(@files) { 130 for(@files) {
100 if( /\.mp[23]$/ && -f "$dir/$_" ) { 131 if( (/\.mp[23]$/i || /\.ogg$/i) && -f "$dir/$_" ) {
101 push @mp3, $_; 132 push @mp3, $_;
102 } 133 }
103 } 134 }
@@ -118,15 +149,15 @@ sub extractdirs {
118 149
119sub singlefile { 150sub singlefile {
120 my ($file) = @_; 151 my ($file) = @_;
152 my $hash;
121 153
122# print "Check $file\n"; 154 if($file =~ /\.ogg$/i) {
123 155 $hash = get_oggtag($file);
124 my $hash = get_mp3tag($file); 156 }
125 # my $hash = get_mp3info($file); 157 else {
158 $hash = get_mp3tag($file);
159 }
126 160
127# for(keys %$hash) {
128# print "Info: $_ ".$hash->{$_}."\n";
129# }
130 return $hash; # a hash reference 161 return $hash; # a hash reference
131} 162}
132 163