only complain about missing albums if $verbose, complain about artists always
authorIan Beckwith <ianb@erislabs.net>
Sat, 2 Oct 2010 00:34:33 +0000 (01:34 +0100)
committerIan Beckwith <ianb@erislabs.net>
Sat, 2 Oct 2010 00:34:33 +0000 (01:34 +0100)
lib/ID3FS/AudioFile/Flac.pm
lib/ID3FS/AudioFile/Mp3.pm
lib/ID3FS/AudioFile/Ogg.pm
lib/ID3FS/DB.pm

index 1eebb2c..c2b02fc 100644 (file)
@@ -19,7 +19,7 @@ sub new
 
 sub get
 {
-    my ($self, $tag, $complain)=@_;
+    my ($self, $tag)=@_;
     for my $key (keys %{$self->{tags}})
     {
        if($key =~ /$tag/i &&
@@ -30,17 +30,15 @@ sub get
            return $self->{tags}->{$key};
        }
     }
-    warn("$self->{path}: no $tag defined in FLAC comments\n") if($complain);
     return undef;
 }
 
-sub artist    { shift->get("ARTIST", 1); }
-sub album     { shift->get("ALBUM", 1);  }
-sub audiotype { return "flac";           }
-sub haspic    { return undef;            } # FIXME
-sub v1genre   { return undef;            } # ID3 only
-# We don't care if year is not set
-sub year      { shift->get("DATE", 0);   }
+sub artist    { shift->get("ARTIST"); }
+sub album     { shift->get("ALBUM");  }
+sub audiotype { return "flac";        }
+sub haspic    { return undef;         } # FIXME
+sub v1genre   { return undef;         } # ID3 only
+sub year      { shift->get("DATE");   }
 
 sub tags
 {
index 8ac84c4..d4faf09 100644 (file)
@@ -26,7 +26,7 @@ sub new
 
 sub choose
 {
-    my ($self, $func, $verbose)=@_;
+    my ($self, $func)=@_;
     my $thing=undef;
     if(defined($self->{v2}))
     {
@@ -36,20 +36,15 @@ sub choose
     {
        $thing=$self->{v1}->$func();
     }
-    if(!defined($thing) || !length($thing))
-    {
-       warn("$self->{path}: no $func defined in ID3 tags\n") if($verbose);
-       return undef;
-    }
     return $thing;
 }
 
-sub artist    { shift->choose("artist", 1); }
-sub album     { shift->choose("album", 1);  }
+sub artist    { shift->choose("artist"); }
+sub album     { shift->choose("album");  }
 # We don't care if year is not set
-sub year      { shift->choose("year", 0);   }
-sub audiotype { return "mp3";               }
-sub haspic    { return undef;               } # FIXME
+sub year      { shift->choose("year");   }
+sub audiotype { return "mp3";            }
+sub haspic    { return undef;            } # FIXME
 sub v1genre
 {
     my($self)=@_;
index a617f9f..649b450 100644 (file)
@@ -19,7 +19,7 @@ sub new
 
 sub get
 {
-    my ($self, $tag, $complain)=@_;
+    my ($self, $tag)=@_;
     for my $commenttype (@{$self->{comments}})
     {
        if($commenttype =~ /$tag/i)
@@ -41,17 +41,15 @@ sub get
            }
        }
     }
-    warn("$self->{path}: no $tag defined in Ogg comments\n") if($complain);
     return undef;
 }
 
-sub artist    { shift->get("Artist", 1); }
-sub album     { shift->get("Album", 1);  }
-sub audiotype { return "ogg";            }
-sub haspic    { return undef;            } # FIXME
-sub v1genre   { return undef;            } # ID3 only
-# We don't care if year is not set
-sub year      { shift->get("Date", 0);   }
+sub artist    { shift->get("Artist"); }
+sub album     { shift->get("Album");  }
+sub audiotype { return "ogg";         }
+sub haspic    { return undef;         } # FIXME
+sub v1genre   { return undef;         } # ID3 only
+sub year      { shift->get("Date");   }
 
 sub tags
 {
index f457905..d149b6a 100644 (file)
@@ -454,9 +454,15 @@ sub add
     my $haspic=$file->haspic();
 
     $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))
+    {
+       print "$self->{me}: $path: no album tag defined\n";
+    }
+
     my $albums_id=$self->add_to_table("albums", $album);
     my $file_id=$self->add_to_table("files", $filepart,
                                    { "artists_id" => $artist_id,
@@ -560,7 +566,7 @@ sub files_in
 {
     my ($self, $dir)=@_;
     $dir=~s/^$self->{base}\/?//;
-    print "Munged dir: $dir\n";
+#    print "Munged dir: $dir\n";
     my $sql=("SELECT files.name FROM files\n" .
             "INNER JOIN paths ON files.paths_id=paths.id\n" .
             "WHERE paths.name=?\n");
@@ -578,7 +584,7 @@ sub prune_directories
     {
        my($path, $id)=@$pathpair;
        my $fullpath="$self->{absbase}/$path";
-       print "PRUNING PATH $fullpath: ";
+#      print "PRUNING PATH $fullpath: ";
        unless(-d $fullpath)
        {
            push(@ids, $id)
@@ -591,6 +597,7 @@ sub prune_directories
 sub prune_paths
 {
     my($self, @ids)=@_;
+    return unless(@ids);
     my $sql=("DELETE FROM files WHERE paths_id IN (\n\t" .
             join(', ', map { "\"$_\""; } @ids). "\n\t)");
     print "SQL: \n", $sql, "\n";