sub get
{
- my ($self, $tag, $complain)=@_;
+ my ($self, $tag)=@_;
for my $key (keys %{$self->{tags}})
{
if($key =~ /$tag/i &&
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
{
sub choose
{
- my ($self, $func, $verbose)=@_;
+ my ($self, $func)=@_;
my $thing=undef;
if(defined($self->{v2}))
{
{
$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)=@_;
sub get
{
- my ($self, $tag, $complain)=@_;
+ my ($self, $tag)=@_;
for my $commenttype (@{$self->{comments}})
{
if($commenttype =~ /$tag/i)
}
}
}
- 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
{
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,
{
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");
{
my($path, $id)=@$pathpair;
my $fullpath="$self->{absbase}/$path";
- print "PRUNING PATH $fullpath: ";
+# print "PRUNING PATH $fullpath: ";
unless(-d $fullpath)
{
push(@ids, $id)
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";