projects
/
app-musicexpo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
88beadc
)
Simplify code
author
Marius Gavrilescu
<marius@ieval.ro>
Sat, 1 Aug 2015 15:46:36 +0000
(18:46 +0300)
committer
Marius Gavrilescu
<marius@ieval.ro>
Sat, 1 Aug 2015 15:46:36 +0000
(18:46 +0300)
lib/App/MusicExpo.pm
patch
|
blob
|
blame
|
history
diff --git
a/lib/App/MusicExpo.pm
b/lib/App/MusicExpo.pm
index 3bdef011a6d7086d7ee766068e190a0271eba187..a55b53ce8497322bc3b5107b5da9dc12d3012725 100644
(file)
--- a/
lib/App/MusicExpo.pm
+++ b/
lib/App/MusicExpo.pm
@@
-119,6
+119,16
@@
sub mp4info{
};
}
};
}
+my %info = (
+ '.flac' => \&flacinfo,
+ '.mp3' => \&mp3info,
+ '.ogg' => \&vorbisinfo,
+ '.oga' => \&vorbisinfo,
+ '.mp4' => \&mp4info,
+ '.aac' => \&mp4info,
+ '.m4a' => \&mp4info,
+);
+
sub normalizer{
"$_[0]|".(stat $_[0])[9]
}
sub normalizer{
"$_[0]|".(stat $_[0])[9]
}
@@
-126,22
+136,17
@@
sub normalizer{
sub make_fragment{ join '-', map { lc =~ y/a-z0-9/_/csr } @_ }
sub run {
sub make_fragment{ join '-', map { lc =~ y/a-z0-9/_/csr } @_ }
sub run {
+ my %info = %info;
if ($cache) {
tie my %cache, 'DB_File', $cache, O_RDWR|O_CREAT, 0644;
if ($cache) {
tie my %cache, 'DB_File', $cache, O_RDWR|O_CREAT, 0644;
-
memoize $_, NORMALIZER => \&normalizer, LIST_CACHE => 'MERGE', SCALAR_CACHE => [HASH => \%cache] for qw/flacinfo mp3info vorbisinfo mp4info/
;
+
$info{$_} = memoize $info{$_}, INSTALL => undef, NORMALIZER => \&normalizer, LIST_CACHE => 'FAULT', SCALAR_CACHE => [HASH => \%cache] for keys %info
;
}
my %files;
for my $file (@ARGV) {
}
my %files;
for my $file (@ARGV) {
- my $info;
- $info = thaw scalar flacinfo $file if $file =~ /\.flac$/i;
- $info = thaw scalar mp3info $file if $file =~ /\.mp3$/i;
- $info = thaw scalar vorbisinfo $file if $file =~ /\.og(?:g|a)$/i;
- $info = thaw scalar mp4info $file if $file =~ /\.mp4|\.aac|\.m4a$/i;
- next unless defined $info;
- my $basename = fileparse $file, '.flac', '.mp3', '.ogg', '.oga', '.mp4', '.aac', '.m4a';
+ my ($basename, undef, $suffix) = fileparse $file, keys %info;
$files{$basename} //= [];
$files{$basename} //= [];
- push @{$files{$basename}},
$info
;
+ push @{$files{$basename}},
thaw scalar $info{$suffix}->($file)
;
}
my $ht=HTML::Template::Compiled->new(
}
my $ht=HTML::Template::Compiled->new(
This page took
0.012063 seconds
and
4
git commands to generate.