1 package ID3FS::AudioFile::Flac;
5 use Audio::FLAC::Header;
10 my $class=ref($proto) || $proto;
15 my $flac=Audio::FLAC::Header->new($self->{path});
16 $self->{tags}=$flac->tags();
22 my ($self, $tag, $complain)=@_;
23 for my $key (keys %{$self->{tags}})
26 defined($self->{tags}->{$key}) &&
27 length($self->{tags}->{$key}) &&
28 $self->{tags}->{$key} =~ /\S+/)
30 my $val=$self->{tags}->{$key};
31 $val =~ s/\//-/g; # drop slashes
35 warn("$self->{path}: no $tag defined in FLAC comments\n") if($complain);
39 sub artist { shift->get("ARTIST", 1); }
40 sub album { shift->get("ALBUM", 1); }
41 sub audiotype { return "flac"; }
42 sub haspic { return undef; } # FIXME
43 sub v1genre { return undef; } # ID3 only
45 # We don't care if year is not set
49 my $date=shift->get("DATE", 0);
50 return undef unless($date);
51 if($date =~/(\d\d\d\d)/)
63 for my $key (keys %{$self->{tags}})
65 if($key =~ /genre/i &&
66 defined($self->{tags}->{$key}) &&
67 length($self->{tags}->{$key}) &&
68 $self->{tags}->{$key} =~ /\S+/)
70 push(@tags, $self->{tags}->{$key});
73 # combine then split on commas
74 # so multiple comma-delimited tags will work
75 @tags=split(/\s*,\s*/, join(', ', @tags));
78 if($tag=~/([^\/]+)\/(.*)/)
83 $tags->{$tagname}=$tagval;