X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2FID3FS%2FAudioFile%2FMp3.pm;h=8133c915dd746061b8aea975130cd4a1212fae9a;hb=a0afb2205afd4fe0ca1e5c52970ccdddc4358f61;hp=d6597d0ab55137c80fce509a29c1ded2b81c20b4;hpb=d36997559c7b3f3550be73d3e1640fc3c93016c6;p=id3fs.git diff --git a/lib/ID3FS/AudioFile/Mp3.pm b/lib/ID3FS/AudioFile/Mp3.pm index d6597d0..8133c91 100644 --- a/lib/ID3FS/AudioFile/Mp3.pm +++ b/lib/ID3FS/AudioFile/Mp3.pm @@ -1,3 +1,19 @@ +# id3fs - a FUSE-based filesystem for browsing audio metadata +# Copyright (C) 2010 Ian Beckwith +# +# 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 . + package ID3FS::AudioFile::Mp3; use strict; @@ -26,7 +42,7 @@ sub new sub choose { - my ($self, $func, $verbose)=@_; + my ($self, $func)=@_; my $thing=undef; if(defined($self->{v2})) { @@ -36,55 +52,29 @@ 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; - } - $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 @@ -108,4 +98,3 @@ sub get_tags } 1; -