new special tags: channels, samplerate, bitrate
[id3fs.git] / lib / ID3FS / DB.pm
index 79cd194..143c568 100644 (file)
@@ -233,13 +233,17 @@ sub add
     my $audiotype=$file->audiotype();
     my @tags=$file->tags();
     my $haspic=$file->haspic();
+    my $channels=$file->channels();
+    my $bitrate=$file->bitrate();
+    my $samplerate=$file->samplerate();
 
     $artist=undef unless($self->ok($artist));
     print "$self->{me}: $path: no artist tag defined\n" unless(defined($artist));
     my $artist_id=$self->add_to_table("artists",  $artist);
     my $path_id=$self->add_to_table("paths", $pathpart);
     $album=undef unless($self->ok($album));
-    if($self->{verbose} && !defined($album))
+#    if($self->{verbose} && !defined($album)) FIXME
+    if(!defined($album))
     {
        print "$self->{me}: $path: no album tag defined\n";
     }
@@ -261,7 +265,7 @@ sub add
        $self->add_tag($file_id, "UNTAGGED");
     }
 
-    $year="UNKNOWN" unless($self->ok($year));
+    $year="UNKNOWN" if(!$self->ok($year) || $year =~ /^0+$/);
     $self->add_tag($file_id, "year", $year);
     if($year=~/^(\d\d\d)\d$/)
     {
@@ -286,6 +290,33 @@ sub add
     {
        $self->add_tag($file_id, "audiotype", $audiotype);
     }
+
+    if($self->ok($channels))
+    {
+       if($channels eq "2")
+       {
+           $self->add_tag($file_id, "channels", "stereo");
+       }
+       elsif($channels eq "1")
+       {
+           $self->add_tag($file_id, "channels", "mono");
+       }
+       else
+       {
+           $self->add_tag($file_id, "channels", $channels);
+       }
+    }
+
+    if($self->ok($bitrate))
+    {
+       $self->add_tag($file_id, "bitrate", $bitrate);
+    }
+
+    if($self->ok($samplerate))
+    {
+       $self->add_tag($file_id, "samplerate", $samplerate);
+    }
+
 }
 
 sub add_tag