Use Audio::Opusfile
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 20 Aug 2016 14:34:56 +0000 (10:34 -0400)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 20 Aug 2016 14:35:28 +0000 (10:35 -0400)
Makefile.PL
lib/App/MusicExpo.pm

index ffbd809f2f2fbee4a17eeece8fd4e4a2dc986ec3..9cb29a95d908696544964a7c0bbf47bf1ef7c097 100644 (file)
@@ -12,6 +12,7 @@ WriteMakefile(
        SIGN             => 1,
        PREREQ_PM        => {
                qw/Audio::FLAC::Header           0
+                  Audio::Opusfile               0
                   HTML::Template::Compiled      0
                   Memoize                       0
                   MP3::Info                     0
index 5eb5a6a840d427b16b8efebd2f442e6ca8f50815..3f8bc42d80152cb8559d6770640cc87470eeb42b 100644 (file)
@@ -11,6 +11,7 @@ use Memoize qw/memoize/;
 use MP3::Info qw/get_mp3tag/;
 use Ogg::Vorbis::Header::PurePerl;
 use MP4::Info qw/get_mp4tag get_mp4info/;
+use Audio::Opusfile qw//;
 
 use DB_File qw//;
 use Encode qw/encode/;
@@ -113,23 +114,18 @@ sub mp4info{
 
 sub opusinfo {
        my $file = $_[0];
-       my %info;
-       my @info = `opusinfo \Q$file`;
-       return unless @info;
-       for (@info) {
-               chomp;
-               $info{$1} = $2 if /\s*([A-Z]+)=(.*)$/;
-       }
+       my $of = Audio::Opusfile->new_from_file($file);
+       my $tags = $of->tags;
 
        my %data = (
                format => 'Opus',
-               title => $info{TITLE},
-               artist => $info{ARTIST},
-               year => $info{DATE},
-               album => $info{ALBUM},
-               tracknumber => $info{TRACKNUMBER},
-               tracktotal => $info{TRACKTOTAL},
-               genre => $info{GENRE},
+               title => $tags->query('TITLE'),
+               artist => $tags->query('ARTIST'),
+               year => $tags->query('DATE'),
+               album => $tags->query('ALBUM'),
+               tracknumber => $tags->query('TRACKNUMBER'),
+               tracktotal => $tags->query('TRACKTOTAL'),
+               genre => $tags->query('GENRE'),
                file => scalar fileparse $file
        );
 
This page took 0.012696 seconds and 4 git commands to generate.