diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2025-11-25 15:38:49 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2025-11-25 15:38:49 -0400 |
| commit | e0ed41638ac5f76968499a16628f7054eae11158 (patch) | |
| tree | 3771f13d308a3cdac56c347d5c3ea6cd8f90a079 /src/data/things/track.js | |
| parent | e4125608ed4f88ba3115ffc888035922c798705c (diff) | |
data: Track: chop withMainRelease
Diffstat (limited to 'src/data/things/track.js')
| -rw-r--r-- | src/data/things/track.js | 91 |
1 files changed, 84 insertions, 7 deletions
diff --git a/src/data/things/track.js b/src/data/things/track.js index 8ae4864d..7712d6c7 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -32,6 +32,7 @@ import { import { exitWithoutDependency, + exitWithoutUpdateValue, exposeConstant, exposeDependency, exposeDependencyOrContinue, @@ -51,6 +52,7 @@ import { withRecontextualizedContributionList, withRedatedContributionList, withResolvedContribs, + withResolvedReference, } from '#composite/wiki-data'; import { @@ -83,7 +85,6 @@ import { inheritFromMainRelease, withAllReleases, withDirectorySuffix, - withMainRelease, withMainReleaseTrack, withOtherReleases, withPropertyFromAlbum, @@ -168,16 +169,92 @@ export class Track extends Thing { // whether or not a matching track is found on a provided album, for // example. When presenting or processing, read `mainReleaseTrack`. mainRelease: [ - withMainRelease({ - from: input.updateValue({ - validate: - validateReference(['album', 'track']), + exitWithoutUpdateValue({ + validate: input.value( + validateReference(['album', 'track'])), + }), + + { + dependencies: ['name'], + transform: (ref, continuation, {name: ownName}) => + (ref === 'same name single' + ? continuation(ref, { + ['#albumOrTrackReference']: null, + ['#sameNameSingleReference']: ownName, + }) + : continuation(ref, { + ['#albumOrTrackReference']: ref, + ['#sameNameSingleReference']: null, + })), + }, + + withResolvedReference({ + ref: '#albumOrTrackReference', + find: soupyFind.input('trackMainReleasesOnly'), + }).outputs({ + '#resolvedReference': '#matchingTrack', + }), + + withResolvedReference({ + ref: '#albumOrTrackReference', + find: soupyFind.input('album'), + }).outputs({ + '#resolvedReference': '#matchingAlbum', + }), + + withResolvedReference({ + ref: '#sameNameSingleReference', + find: soupyFind.input('albumSinglesOnly'), + findOptions: input.value({ + fuzz: { + capitalization: true, + kebab: true, + }, }), + }).outputs({ + '#resolvedReference': '#sameNameSingle', }), - exposeDependency({ - dependency: '#mainRelease', + exposeDependencyOrContinue({ + dependency: '#sameNameSingle', + }), + + { + dependencies: [ + '#matchingTrack', + '#matchingAlbum', + ], + + compute: (continuation, { + ['#matchingTrack']: matchingTrack, + ['#matchingAlbum']: matchingAlbum, + }) => + (matchingTrack && matchingAlbum + ? continuation() + : matchingTrack ?? matchingAlbum + ? matchingTrack ?? matchingAlbum + : null), + }, + + withPropertyFromObject({ + object: '#matchingAlbum', + property: input.value('tracks'), }), + + { + dependencies: [ + '#matchingAlbum.tracks', + '#matchingTrack', + ], + + compute: ({ + ['#matchingAlbum.tracks']: matchingAlbumTracks, + ['#matchingTrack']: matchingTrack, + }) => + (matchingAlbumTracks.includes(matchingTrack) + ? matchingTrack + : null), + }, ], bandcampTrackIdentifier: simpleString(), |