« get me outta code hell

data: LyricsEntry & co - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/yaml.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-04-14 21:16:30 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-16 13:03:15 -0300
commitbe421bae8d73ae06e66c705a6c78858bcf8568c3 (patch)
treee3e3b24e96172309fed81d6c890756f33b4e482a /src/data/yaml.js
parent14f9c99b13e499068b36ca67142fc20c3b3732a2 (diff)
data: LyricsEntry & co
Diffstat (limited to 'src/data/yaml.js')
-rw-r--r--src/data/yaml.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js
index e6b3fa71..847489f0 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -11,7 +11,8 @@ import {colors, ENABLE_COLOR, logInfo, logWarn} from '#cli';
 import {sortByName} from '#sort';
 import Thing from '#thing';
 import thingConstructors from '#things';
-import {matchCommentaryEntries} from '#wiki-data';
+import {matchCommentaryEntries, multipleLyricsDetectionRegex}
+  from '#wiki-data';
 
 import {
   aggregateThrows,
@@ -825,7 +826,7 @@ export function parseArtwork({
   return transform;
 }
 
-export function parseCommentary(sourceText, {subdoc, CommentaryEntry}) {
+export function parseContentEntries(thingClass, sourceText, {subdoc}) {
   const map = matchEntry => ({
     'Artists':
       matchEntry.artistReferences
@@ -869,11 +870,29 @@ export function parseCommentary(sourceText, {subdoc, CommentaryEntry}) {
 
   const subdocs =
     documents.map(document =>
-      subdoc(CommentaryEntry, document, {bindInto: 'thing'}));
+      subdoc(thingClass, document, {bindInto: 'thing'}));
 
   return subdocs;
 }
 
+export function parseCommentary(sourceText, {subdoc, CommentaryEntry}) {
+  return parseContentEntries(CommentaryEntry, sourceText, {subdoc});
+}
+
+export function parseCreditingSources(sourceText, {subdoc, CreditingSourcesEntry}) {
+  return parseContentEntries(CreditingSourcesEntry, sourceText, {subdoc});
+}
+
+export function parseLyrics(sourceText, {subdoc, LyricsEntry}) {
+  if (!multipleLyricsDetectionRegex.test(sourceText)) {
+    const document = {'Body': sourceText};
+
+    return [subdoc(LyricsEntry, document, {bindInto: 'thing'})];
+  }
+
+  return parseContentEntries(LyricsEntry, sourceText, {subdoc});
+}
+
 // documentModes: Symbols indicating sets of behavior for loading and processing
 // data files.
 export const documentModes = {
@@ -1567,6 +1586,8 @@ export function linkWikiDataArrays(wikiData, {bindFind, bindReverse}) {
 
     ['homepageLayout.sections.rows', [/* find */]],
 
+    ['lyricsData', [/* find */]],
+
     ['trackData', [
       'artworkData',
       'trackData',