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
}
<tr><td>Cellule<td>Silence<td>L'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';