« get me outta code hell

content: generateAlbumReleaseInfo: fix unexpected _:__ duration - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-06-12 16:58:10 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-12 17:00:21 -0300
commit93e9593fd091e4153ec0a3fcc1e09484fe1f045b (patch)
tree37f570a2409e49d8a5d7978c30991f4e6778aafd /src/content
parent975f41b208e220360d9539c31464aa4391d7dfa4 (diff)
content: generateAlbumReleaseInfo: fix unexpected _:__ duration
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateAlbumReleaseInfo.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/content/dependencies/generateAlbumReleaseInfo.js b/src/content/dependencies/generateAlbumReleaseInfo.js
index 1cd638ce..26e2e160 100644
--- a/src/content/dependencies/generateAlbumReleaseInfo.js
+++ b/src/content/dependencies/generateAlbumReleaseInfo.js
@@ -1,4 +1,4 @@
-import {accumulateSum} from '#sugar';
+import {accumulateSum, empty} from '#sugar';
 
 export default {
   contentDependencies: [
@@ -41,8 +41,18 @@ export default {
       data.coverArtDate = album.coverArtDate;
     }
 
-    data.duration = accumulateSum(album.tracks, track => track.duration);
-    data.durationApproximate = album.tracks.length > 1;
+    const durationTerms =
+      album.tracks
+        .map(track => track.duration)
+        .filter(value => value > 0);
+
+    if (empty(durationTerms)) {
+      data.duration = null;
+      data.durationApproximate = null;
+    } else {
+      data.duration = accumulateSum(durationTerms);
+      data.durationApproximate = album.tracks.length > 1;
+    }
 
     data.numTracks = album.tracks.length;