From: Marius Gavrilescu Date: Sat, 1 Aug 2015 18:19:20 +0000 (+0300) Subject: Replace MP3::Tag with MP3::Info X-Git-Tag: 1.000~8 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=b8e18bed40c5ec5d39b19acc2e380b3efbd4b807;p=app-musicexpo.git Replace MP3::Tag with MP3::Info --- diff --git a/Makefile.PL b/Makefile.PL index 89e82bd..ffbd809 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -14,7 +14,7 @@ WriteMakefile( qw/Audio::FLAC::Header 0 HTML::Template::Compiled 0 Memoize 0 - MP3::Tag 1.12 + MP3::Info 0 MP4::Info 0 DB_File 0 Ogg::Vorbis::Header::PurePerl 0/, diff --git a/lib/App/MusicExpo.pm b/lib/App/MusicExpo.pm index f23063b..1945687 100644 --- a/lib/App/MusicExpo.pm +++ b/lib/App/MusicExpo.pm @@ -8,11 +8,12 @@ our $VERSION = '0.005'; use Audio::FLAC::Header qw//; use HTML::Template::Compiled qw//; use Memoize qw/memoize/; -use MP3::Tag qw//; +use MP3::Info qw/get_mp3tag/; use Ogg::Vorbis::Header::PurePerl; use MP4::Info qw/get_mp4tag get_mp4info/; use DB_File qw//; +use Encode qw/encode/; use File::Basename qw/fileparse/; use Fcntl qw/O_RDWR O_CREAT/; use Getopt::Long; @@ -35,7 +36,6 @@ GetOptions ( sub flacinfo{ my $file=$_[0]; my $flac=Audio::FLAC::Header->new($file); - $file = scalar fileparse $file; freeze +{ format => 'FLAC', @@ -46,32 +46,31 @@ sub flacinfo{ tracknumber => $flac->tags('TRACKNUMBER') // '?', tracktotal => $flac->tags('TRACKTOTAL') // '?', genre => $flac->tags('GENRE') // '?', - file => $file, + file => scalar fileparse $file, } } sub mp3info{ my $file=$_[0]; - my $mp3=MP3::Tag->new($file); - $file = scalar fileparse $file; + my %tag = map { encode 'UTF-8', $_ } %{get_mp3tag $file}; + my @trkn = split '/', $tag{TRACKNUM} // ''; freeze +{ format => 'MP3', - title => $mp3->title || '?', - artist => $mp3->artist || '?', - year => $mp3->year || '?', - album => $mp3->album || '?', - tracknumber => $mp3->track1 || '?', - tracktotal => $mp3->track2 || '?', - genre => $mp3->genre || '?', - file => $file, + title => $tag{TITLE} || '?', + artist => $tag{ARTIST} || '?', + year => $tag{YEAR} || '?', + album => $tag{ALBUM} || '?', + tracknumber => $trkn[0] || '?', + tracktotal => $trkn[1] || '?', + genre => $tag{GENRE} || '?', + file => scalar fileparse $file, } } sub vorbisinfo{ my $file=$_[0]; my $ogg=Ogg::Vorbis::Header::PurePerl->new($file); - $file = scalar fileparse $file; freeze +{ format => 'Vorbis', @@ -82,7 +81,7 @@ sub vorbisinfo{ tracknumber => $ogg->comment('TRACKNUMBER') || '?', tracktotal => $ogg->comment('TRACKTOTAL') || '?', genre => $ogg->comment('GENRE') || '?', - file => $file, + file => scalar fileparse $file, } } @@ -95,9 +94,8 @@ sub mp4_format ($){ sub mp4info{ my $file=$_[0]; - my %tag = %{get_mp4tag $file}; + my %tag = map { ref() ? $_ : encode 'UTF-8', $_ } %{get_mp4tag $file}; my %info = %{get_mp4info $file}; - $file = scalar fileparse $file; freeze +{ format => mp4_format $info{ENCODING}, @@ -108,7 +106,7 @@ sub mp4info{ tracknumber => $tag{TRACKNUM} || '?', tracktotal => ($tag{TRKN} ? $tag{TRKN}->[1] : undef) || '?', genre => $tag{GENRE} || '?', - file => $file, + file => scalar fileparse $file, }; }