1 package ID3FS::File::Ogg;
5 use Ogg::Vorbis::Header;
10 my $class=ref($proto) || $proto;
15 $self->{ogg}=Ogg::Vorbis::Header->new($self->{path});
16 $self->{comments}=[ $self->{ogg}->comment_tags() ];
22 my ($self, $tag, $complain)=@_;
23 for my $commenttype (@{$self->{comments}})
25 if($commenttype =~ /$tag/i)
27 my @comments=$self->{ogg}->comment($commenttype);
30 # take first comment with actual contents
31 while(my $comment=shift @comments)
33 if(defined($comment) &&
37 $comment =~ s/\//-/g; # drop slashes
44 warn("$self->{path}: no $tag defined in Ogg comments\n") if($complain);
48 sub artist { shift->get("Artist", 1); }
49 sub album { shift->get("Album", 1); }
50 sub audiotype { return "ogg"; }
51 sub haspic { return undef; } # FIXME
52 sub v1genre { return undef; } # ID3 only
54 # We don't care if year is not set
58 my $date=shift->get("Date", 0);
59 return undef unless($date);
60 if($date =~/(\d\d\d\d)/)
71 for my $commenttype (@{$self->{comments}})
73 if($commenttype =~ /genre/i)
75 push(@comments,$self->{ogg}->comment($commenttype));
81 # filter for useful comments
82 @comments= grep { defined($_); } @comments;
83 @comments= grep { length($_); } @comments;
84 @comments= grep { /\S+/; } @comments;
85 # combine then split on commas
86 # so multiple comma-delimited tags will work
87 @comments=split(/\s*,\s*/, join(', ', @comments));
88 for my $comment (@comments)
90 if($comment=~/([^\/]+)\/(.*)/)
95 $tags->{$tagname}=$tagval;
99 $tags->{$comment}=undef;