X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FApp%2FMusicExpo.pm;h=e9c0b9579e5556e2839a860ce2aa727ec46bf549;hb=cc5d06b5c1cb910dd20e39a43a399dd1652f926d;hp=60c5c087156164daec33bcb3d09cdb3b13537052;hpb=598a92c5fd17bb4e57ad3ab108c8fb394fae0c90;p=app-musicexpo.git
diff --git a/lib/App/MusicExpo.pm b/lib/App/MusicExpo.pm
index 60c5c08..e9c0b95 100644
--- a/lib/App/MusicExpo.pm
+++ b/lib/App/MusicExpo.pm
@@ -3,7 +3,7 @@ use v5.14;
use strict;
use warnings;
-our $VERSION = 0.003001;
+our $VERSION = '0.003003';
use Audio::FLAC::Header qw//;
use HTML::Template::Compiled qw//;
@@ -15,6 +15,7 @@ use DB_File qw//;
use File::Basename qw/fileparse/;
use Fcntl qw/O_RDWR O_CREAT/;
use Getopt::Long;
+use JSON::MaybeXS;
use Storable qw/thaw freeze/;
##################################################
@@ -97,10 +98,10 @@ sub normalizer{
}
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 '';
+ 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/;
+ }
my %files;
for my $file (@ARGV) {
@@ -128,7 +129,10 @@ sub run {
push @files, \%entry
}
- $ht->param(files=>[sort { $a->{title} cmp $b->{title} } @files], prefix => $prefix);
+ my $json = JSON::MaybeXS->new(canonical => 1)->encode({files => \@files, prefix => $prefix});
+ $json =~ s/</g;
+ $json =~ s/>/>/g;
+ $ht->param(files=>[sort { $a->{title} cmp $b->{title} } @files], prefix => $prefix, json => $json);
print $ht->output;
}
@@ -142,14 +146,18 @@ $default_template = <<'HTML';
Title Artist Album Genre Track Year Type