X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2FID3FS%2FDB.pm;h=5821b538cb6e8633c406abe2896b2391ca5f700d;hb=f768e5fc4f33962bfac1142c546776cc0e239ec0;hp=909d7f16d711c77cfe0b7d5c05aaa48fb3ee66a6;hpb=ac4b1523cdb6cf2dbdbdea60196ffbd84ffc7a45;p=id3fs.git diff --git a/lib/ID3FS/DB.pm b/lib/ID3FS/DB.pm index 909d7f1..5821b53 100644 --- a/lib/ID3FS/DB.pm +++ b/lib/ID3FS/DB.pm @@ -152,9 +152,10 @@ sub last_update sub bare_tags { my($self)=@_; - my $sql=("SELECT tags.name FROM tags\n" . - "WHERE tags.parents_id=''\n" . - "GROUP BY tags.name\n"); + my $sql=("SELECT t1.name FROM tags t1\n" . + "LEFT JOIN tags t2 on t1.id=t2.parents_id\n" . + "WHERE t1.parents_id='' AND t2.id IS NULL\n" . + "GROUP BY t1.name\n"); my @names=$self->cmd_firstcol($sql); return (@names); } @@ -233,13 +234,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"; } @@ -249,12 +254,20 @@ sub add { "artists_id" => $artist_id, "albums_id" => $albums_id, "paths_id" => $path_id }); - for my $tag (@tags) + if(@tags) { - $self->add_tag($file_id, @$tag); + for my $tag (@tags) + { + $self->add_tag($file_id, @$tag); + } + } + else + { + $self->add_tag($file_id, "UNTAGGED"); } - $year="UNKNOWN" unless($self->ok($year)); + $year="UNKNOWN" if(!$self->ok($year) || $year =~ /^0+$/); + $year+=1900 if($year=~/^\d\d$/); $self->add_tag($file_id, "year", $year); if($year=~/^(\d\d\d)\d$/) { @@ -279,6 +292,32 @@ sub add { $self->add_tag($file_id, "audiotype", $audiotype); } + else + { + # should never happen + $self->add_tag($file_id, "audiotype", "UNKNOWN"); + } + + if($self->ok($channels)) + { + if ($channels eq "2") { $channels="stereo"; } + elsif ($channels eq "1") { $channels="mono"; } + elsif ($channels eq "0") { $channels="UNKNOWN"; } + $self->add_tag($file_id, "channels", $channels); + } + + if($self->ok($bitrate)) + { + $bitrate="UNKNOWN" if($bitrate=~/^0+$/); + $self->add_tag($file_id, "bitrate", $bitrate); + } + + if($self->ok($samplerate)) + { + $samplerate="UNKNOWN" if($samplerate=~/^0+$/); + $self->add_tag($file_id, "samplerate", $samplerate); + } + } sub add_tag