+# id3fs - a FUSE-based filesystem for browsing audio metadata
+# Copyright (C) 2010 Ian Beckwith <ianb@erislabs.net>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
package ID3FS::AudioFile::Mp3;
use strict;
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;
- }
- $thing=~s/\//-/g; # drop slashes
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; } # NEXTVERSION
+
sub v1genre
{
my($self)=@_;
my $genre=undef;
- if(defined($self->{v1}))
- {
- $genre=$self->{v1}->genre();
- $genre =~ s/\//-/g if(defined($genre));
- }
+ $genre=$self->{v1}->genre() if(defined($self->{v1}));
return $genre;
}
sub tags
{
my $self=shift;
- return({}) unless(exists($self->{mp3}->{ID3v2}) && defined($self->{mp3}->{ID3v2}));
- my $genre=$self->{mp3}->{ID3v2}->genre();
- return({}) unless(defined($genre) && length($genre));
- my @tags=split(/\s*,\s*/, $genre);
- for my $tag (@tags)
- {
- if($tag=~/([^\/]+)\/(.*)/)
- {
- my $tagname=$1;
- my $tagval=$2;
- $tagval=~s/\//-/g;
- $self->{tags}->{$tagname}=$tagval;
- }
- else
- {
- $self->{tags}->{$tag}=undef;
- }
- }
- return $self->{tags};
+ return() unless(exists($self->{mp3}->{ID3v2}) && defined($self->{mp3}->{ID3v2}));
+ return($self->{mp3}->{ID3v2}->genre());
}
sub get_tags
}
1;
-