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;
sub flacinfo{
my $file=$_[0];
my $flac=Audio::FLAC::Header->new($file);
- $file = scalar fileparse $file;
freeze +{
format => 'FLAC',
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',
tracknumber => $ogg->comment('TRACKNUMBER') || '?',
tracktotal => $ogg->comment('TRACKTOTAL') || '?',
genre => $ogg->comment('GENRE') || '?',
- file => $file,
+ file => scalar fileparse $file,
}
}
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},
tracknumber => $tag{TRACKNUM} || '?',
tracktotal => ($tag{TRKN} ? $tag{TRKN}->[1] : undef) || '?',
genre => $tag{GENRE} || '?',
- file => $file,
+ file => scalar fileparse $file,
};
}