Use tags from all versions instead of only the first
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 25 Oct 2014 12:08:23 +0000 (15:08 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 25 Oct 2014 12:08:23 +0000 (15:08 +0300)
lib/App/MusicExpo.pm
t/musicexpo-cache.t

index ebee6efc784f18ae802565dcc0c3a02a79fd8e81..a6c21a594260ba38e79c593b7f7f762f14229ae1 100644 (file)
@@ -153,7 +153,13 @@ sub run {
        for (values %files) {
                my @versions = @$_;
                my %entry = (%{$versions[0]}, formats => []);
-               push $entry{formats}, {format => $_->{format}, file => $_->{file}} for @versions;
+               for my $ver (@versions) {
+                       push $entry{formats}, {format => $ver->{format}, file => $ver->{file}};
+                       for my $key (keys $ver) {
+                               $entry{$key} = $ver->{$key} if $ver->{$key} ne '?';
+                       }
+               }
+               delete $entry{$_} for qw/format file/;
                push @files, \%entry
        }
 
index ac4afc4f05b014555a96480e2b8c78905b1fc506..70972a1b8882b34106254376eb2d6003a487b06e 100644 (file)
@@ -35,7 +35,7 @@ is $out, <<'OUT', 'output is correct';
 <tr><td>Cellule<td>Silence<td>L&#39;autre endroit<td>Electro<td>01/09<td>2005<td><a href="/music/empty.flac">FLAC</a> <a href="/music/empty.mp3">MP3</a> 
 </table>
 
-<pre id="json" style="display: none">{"files":[{"album":"L'autre endroit","artist":"Silence","file":"empty.flac","format":"FLAC","formats":[{"file":"empty.flac","format":"FLAC"},{"file":"empty.mp3","format":"MP3"}],"genre":"Electro","title":"Cellule","tracknumber":"01","tracktotal":"09","year":"2005"}],"prefix":"/music/"}</pre>
+<pre id="json" style="display: none">{"files":[{"album":"L'autre endroit","artist":"Silence","formats":[{"file":"empty.flac","format":"FLAC"},{"file":"empty.mp3","format":"MP3"}],"genre":"Electro","title":"Cellule","tracknumber":"01","tracktotal":"09","year":"2005"}],"prefix":"/music/"}</pre>
 OUT
 
 ok -e $file, 'cache exists';
This page took 0.012656 seconds and 4 git commands to generate.