« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/MusicVideo.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things/MusicVideo.js')
-rw-r--r--src/data/things/MusicVideo.js38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/data/things/MusicVideo.js b/src/data/things/MusicVideo.js
index 3a41caf5..77c8c619 100644
--- a/src/data/things/MusicVideo.js
+++ b/src/data/things/MusicVideo.js
@@ -167,6 +167,32 @@ export class MusicVideo extends Thing {
 
     musicVideoContributorContributionsBy:
       soupyReverse.contributionsBy('musicVideoData', 'contributorContribs'),
+
+    musicVideoArtistContributionsToAlbumsBy: {
+      bindTo: 'musicVideoData',
+
+      referencing: musicVideo => musicVideo.artistContribs,
+
+      *referenced(musicVideoContrib) {
+        const musicVideo = musicVideoContrib.thing;
+        const trackOrAlbum = musicVideo.thing;
+        if (trackOrAlbum.isTrack) {
+          const albumArtists =
+            trackOrAlbum.album.artistContribs
+              .map(albumContrib => albumContrib.artist);
+
+          for (const trackContrib of trackOrAlbum.artistContribs) {
+            if (albumArtists.includes(trackContrib.artist)) {
+              yield trackContrib.artist;
+            }
+          }
+        } else {
+          for (const albumContrib of trackOrAlbum.artistContribs) {
+            yield albumContrib.artist;
+          }
+        }
+      },
+    },
   };
 
   get path() {
@@ -179,7 +205,15 @@ export class MusicVideo extends Thing {
   [inspect.custom](depth, options, inspect) {
     const parts = [];
 
-    parts.push(Thing.prototype[inspect.custom].apply(this));
+    parts.push(this.constructor.name);
+
+    if (this.title) {
+      parts.push(` ${colors.green(`"${this.title}"`)}`);
+    } else if (this.label) {
+      parts.push(` (${colors.green(`"${this.label}"`)})`);
+    } else if (this.unqualifiedDirectory !== 'music-video') {
+      parts.push(` (${colors.blue(this.unqualifiedDirectory)})`);
+    }
 
     if (this.thing) {
       if (depth >= 0) {
@@ -193,7 +227,7 @@ export class MusicVideo extends Thing {
 
         parts.push(` for ${inspect(this.thing, newOptions)}`);
       } else {
-        parts.push(` for ${colors.blue(Thing.getReference(this.thing))}`);
+        parts.push(` for ${colors.blue(Thing.inspectReference(this.thing))}`);
       }
     }