Add OGG Vorbis support
authorMarius Gavrilescu <marius@ieval.ro>
Mon, 2 Sep 2013 21:45:27 +0000 (00:45 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Mon, 2 Sep 2013 21:45:27 +0000 (00:45 +0300)
Makefile.PL
lib/App/MusicExpo.pm

index 06f4c1248f81deaf37e7baa010cce4c2b2683819..31d11bc204def2b89612bc743644b02a44663835 100644 (file)
@@ -5,11 +5,12 @@ WriteMakefile(
   NAME          => 'App::MusicExpo',
   VERSION_FROM  => 'lib/App/MusicExpo.pm',
   PREREQ_PM     => {
-       'Audio::FLAC::Header'      => 0,
-       'HTML::Template::Compiled' => 0,
-       'Memoize'                  => 0,
-       'MP3::Tag'                 => 1.12,
-       'DB_File'                  => 0,
+       'Audio::FLAC::Header'           => 0,
+       'HTML::Template::Compiled'      => 0,
+       'Memoize'                       => 0,
+       'MP3::Tag'                      => 1.12,
+       'DB_File'                       => 0,
+       'Ogg::Vorbis::Header::PurePerl' => 0,
   },
   MIN_PERL_VERSION => 5.014,
   EXE_FILES     => [ 'musicexpo' ],
index 3c0f4b7ae88f0fb79946ee5b3698408936ff4f6f..68ef5da343684d16c663baedd20dac699de8b7f1 100644 (file)
@@ -7,6 +7,7 @@ use Audio::FLAC::Header qw//;
 use HTML::Template::Compiled qw//;
 use Memoize qw/memoize/;
 use MP3::Tag qw//;
+use Ogg::Vorbis::Header::PurePerl;
 
 use DB_File qw//;
 use File::Basename qw/fileparse/;
@@ -70,6 +71,23 @@ sub mp3info{
   }
 }
 
+sub vorbisinfo{
+  my $file=$_[0];
+  my $ogg=Ogg::Vorbis::Header::PurePerl->new($file);
+
+  freeze +{
+       format => 'Vorbis',
+       title => fix($ogg->comment('TITLE') || '?'),
+       artist => fix ($ogg->comment('artist') || '?'),
+       year => fix ($ogg->comment('DATE') || '?'),
+       album => fix ($ogg->comment('ALBUM') || '?'),
+       tracknumber => fix ($ogg->comment('TRACKNUMBER') || '?'),
+       tracktotal => fix ($ogg->comment('TRACKTOTAL') || '?'),
+       genre => fix ($ogg->comment('GENRE')) || '?',
+       path => $file,
+  }
+}
+
 sub normalizer{
   "$_[0]|".(stat $_[0])[9]
 }
@@ -78,11 +96,13 @@ sub run {
   tie my %cache, 'DB_File', $cache, O_RDWR|O_CREAT, 0644 unless $cache eq '';
   memoize 'flacinfo', NORMALIZER => \&normalizer, LIST_CACHE => 'MERGE', SCALAR_CACHE => [HASH => \%cache] unless $cache eq '';
   memoize 'mp3info' , NORMALIZER => \&normalizer, LIST_CACHE => 'MERGE', SCALAR_CACHE => [HASH => \%cache] unless $cache eq '';
+  memoize 'vorbisinfo' , NORMALIZER => \&normalizer, LIST_CACHE => 'MERGE', SCALAR_CACHE => [HASH => \%cache] unless $cache eq '';
 
   my @files;
   for my $file (@ARGV) {
        push @files, thaw flacinfo $file if $file =~ /.flac$/i;
        push @files, thaw mp3info $file if $file =~ /.mp3$/i;
+       push @files, thaw vorbisinfo $file if $file =~ /.og(?:g|a)$/i;
   }
 
   my $ht=HTML::Template::Compiled->new(
This page took 0.012435 seconds and 4 git commands to generate.