X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2FID3FS%2FFile%2FOgg.pm;h=ed6c17ab76f5799b5d65f69d230f62c79cce3d27;hb=7d9b32e0f8dbac79f161e4e1848ff12c261e9e84;hp=f05d8c255188a670dd04d407b2a989df51b56e8f;hpb=cce115b26088d4e3122d9f9281adf723ad56dbad;p=id3fs.git diff --git a/lib/ID3FS/File/Ogg.pm b/lib/ID3FS/File/Ogg.pm index f05d8c2..ed6c17a 100644 --- a/lib/ID3FS/File/Ogg.pm +++ b/lib/ID3FS/File/Ogg.pm @@ -13,28 +13,35 @@ sub new $self->{path}=shift; $self->{ogg}=Ogg::Vorbis::Header->new($self->{path}); + $self->{comments}=[ $self->{ogg}->comment_tags() ]; return $self; } sub get { - my ($self, $tag, $verbose)=@_; - my @comments=$self->{ogg}->comment($tag); - if(@comments) + my ($self, $tag, $complain)=@_; + for my $commenttype (@{$self->{comments}}) { - # take first comment with actual contents - while(my $comment=shift @comments) + if($commenttype =~ /$tag/i) { - if(defined($comment) && - length($comment) && - $comment =~ /\S+/) + my @comments=$self->{ogg}->comment($commenttype); + if(@comments) { - $comment =~ s/\//-/g; # drop slashes - return $comment; + # take first comment with actual contents + while(my $comment=shift @comments) + { + if(defined($comment) && + length($comment) && + $comment =~ /\S+/) + { + $comment =~ s/\//-/g; # drop slashes + return $comment; + } + } } } } - warn("$self->{path}: no $tag defined in Ogg comments\n") if($verbose); + warn("$self->{path}: no $tag defined in Ogg comments\n") if($complain); return undef; } @@ -60,7 +67,14 @@ sub year sub tags { my $self=shift; - my @comments=$self->{ogg}->comment("Genre"); + my @comments; + for my $commenttype (@{$self->{comments}}) + { + if($commenttype =~ /genre/i) + { + push(@comments,$self->{ogg}->comment($commenttype)); + } + } my $tags={}; if(@comments) { @@ -68,6 +82,9 @@ sub tags @comments= grep { defined($_); } @comments; @comments= grep { length($_); } @comments; @comments= grep { /\S+/; } @comments; + # combine then split on commas + # so multiple comma-delimited tags will work + @comments=split(/\s*,\s*/, join(', ', @comments)); for my $comment (@comments) { if($comment=~/([^\/]+)\/(.*)/)