398a16993324949b42050c5fb7ca34e2190986a2
[id3fs.git] / lib / ID3FS / AudioFile.pm
1 package ID3FS::AudioFile;
2
3 use strict;
4 use warnings;
5 use ID3FS::AudioFile::Mp3;
6 use ID3FS::AudioFile::Ogg;
7 use ID3FS::AudioFile::Flac;
8
9 sub new
10 {
11     my $proto=shift;
12     my $class=ref($proto) || $proto;
13     my $self={};
14     bless($self,$class);
15
16     my $path=shift;
17     my $ext=($path=~/.*\.(.*)/)[0];
18     return undef unless($ext);
19     $ext=lc($ext);
20     if($ext eq "mp3")
21     {
22         $self->{audiofile}=ID3FS::AudioFile::Mp3->new($path);
23     }
24     elsif($ext eq "ogg")
25     {
26         $self->{audiofile}=ID3FS::AudioFile::Ogg->new($path);
27     }
28     elsif($ext eq "flac")
29     {
30         $self->{audiofile}=ID3FS::AudioFile::Flac->new($path);
31     }
32     else
33     {
34         print("Unknown extension: $ext\n");
35         return undef;
36     }
37 }
38
39 sub artist
40 {
41     return shift->{audiofile}->artist(@_);
42 }
43 sub album
44 {
45     return shift->{audiofile}->album(@_);
46 }
47 sub audiotype
48 {
49     return shift->{audiofile}->audiotype(@_);
50 }
51 sub haspic
52 {
53     return shift->{audiofile}->haspic(@_);
54 }
55 sub v1genre
56 {
57     return shift->{audiofile}->v1genre(@_);
58 }
59 sub year
60 {
61     return shift->{audiofile}->year(@_);
62 }
63 sub tags
64 {
65     return shift->{audiofile}->tags(@_);
66 }
67
68 1;