start refactoring AudioFile
authorIan Beckwith <ianb@erislabs.net>
Sun, 26 Sep 2010 05:36:42 +0000 (06:36 +0100)
committerIan Beckwith <ianb@erislabs.net>
Sun, 26 Sep 2010 05:36:42 +0000 (06:36 +0100)
lib/ID3FS/AudioFile.pm

index b2e5709..398a169 100644 (file)
@@ -6,24 +6,28 @@ use ID3FS::AudioFile::Mp3;
 use ID3FS::AudioFile::Ogg;
 use ID3FS::AudioFile::Flac;
 
-# omg a factory class, I feel vaguely dirty
 sub new
 {
-    my (undef,$path)=@_;
+    my $proto=shift;
+    my $class=ref($proto) || $proto;
+    my $self={};
+    bless($self,$class);
+
+    my $path=shift;
     my $ext=($path=~/.*\.(.*)/)[0];
     return undef unless($ext);
     $ext=lc($ext);
     if($ext eq "mp3")
     {
-       return ID3FS::AudioFile::Mp3->new($path);
+       $self->{audiofile}=ID3FS::AudioFile::Mp3->new($path);
     }
     elsif($ext eq "ogg")
     {
-       return ID3FS::AudioFile::Ogg->new($path);
+       $self->{audiofile}=ID3FS::AudioFile::Ogg->new($path);
     }
     elsif($ext eq "flac")
     {
-       return ID3FS::AudioFile::Flac->new($path);
+       $self->{audiofile}=ID3FS::AudioFile::Flac->new($path);
     }
     else
     {
@@ -32,4 +36,33 @@ sub new
     }
 }
 
+sub artist
+{
+    return shift->{audiofile}->artist(@_);
+}
+sub album
+{
+    return shift->{audiofile}->album(@_);
+}
+sub audiotype
+{
+    return shift->{audiofile}->audiotype(@_);
+}
+sub haspic
+{
+    return shift->{audiofile}->haspic(@_);
+}
+sub v1genre
+{
+    return shift->{audiofile}->v1genre(@_);
+}
+sub year
+{
+    return shift->{audiofile}->year(@_);
+}
+sub tags
+{
+    return shift->{audiofile}->tags(@_);
+}
+
 1;