]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
fixed #10. Multiple medias per release
authorBanana <mail@bananas-playground.net>
Sun, 11 Jul 2021 14:57:51 +0000 (16:57 +0200)
committerBanana <mail@bananas-playground.net>
Sun, 11 Jul 2021 14:57:51 +0000 (16:57 +0200)
webclient/lib/musicbrainz.class.php

index c7184ef7c66bfda3e42445f1def39283f3d95b43..e492567b8ae54acf52454d770c750d77752020d4 100644 (file)
@@ -195,14 +195,17 @@ class Musicbrainz {
                                $ret['tracks'] = '';
                                $ret['image'] = '';
                                $ret['runtime'] = 0;
-                               foreach($data['media'][0]['tracks'] as $track) {
-                                       $ret['runtime'] += $track['length'];
-                                       $l = $track['length'] / 1000;
-                                       $l = date("i:s",$l);
-                                       $ret['tracks'] .= $track['number'].' - '.$track['title'].' - '.$l."\n";
+
+                               foreach($data['media'] as $media) {
+                                       foreach($media['tracks'] as $track) {
+                                               $ret['runtime'] += $track['length'];
+                                               $l = $track['length'] / 1000;
+                                               $l = date("i:s",$l);
+                                               $ret['tracks'] .= $track['number'].' - '.$track['title'].' - '.$l."\n";
+                                       }
                                }
-                               $ret['runtime'] = $ret['runtime'] / 1000;
-                               $ret['runtime'] = date("i",$ret['runtime']);
+
+                               $ret['runtime'] = round($ret['runtime'] / 1000 / 60);
 
                                // image
                                $do = $this->_curlCall($this->_IMAGE_ENDPOINT.$releaseId);