Merge pull request #799 from got-feedBack/chore/lyrics-source-transcribed

Accept spec lyrics_source values (authored, transcribed)
This commit is contained in:
K. O. A.
2026-07-06 17:31:11 -04:00
committed by GitHub
+26 -14
View File
@@ -703,20 +703,32 @@ def load_song(
and isinstance(e.get("d"), (int, float)) and isinstance(e.get("d"), (int, float))
] ]
if song.lyrics: if song.lyrics:
# Provenance — populated by the converter (xml/notechart), # Provenance. The feedpak spec (§7.1) vocabulary is
# the WhisperX fallback (whisperx), or hand-edits # {authored, transcribed, user}; older manifests + the
# (user). Validate against the closed enum so a # in-tree readers also use the source-format names
# hand-edited (or otherwise malformed) manifest can't # (xml/notechart) and the WhisperX engine name
# propagate a YAML dict / list / arbitrary string # (whisperx). Accept the union so both spec-compliant
# into the highway WS `lyrics.source` field and out # writers (e.g. the stem_splitter plugin emitting
# to plugin badges. Anything outside the enum (or # `transcribed`) and legacy packs validate. Validate
# the wrong type) falls back to "xml" — the spec's # against the closed enum so a hand-edited (or otherwise
# back-compat default — instead of being stringified # malformed) manifest can't propagate a YAML dict / list /
# and trusted. # arbitrary string into the highway WS `lyrics.source`
_ALLOWED_LYRICS_SOURCES = {"xml", "notechart", "whisperx", "user"} # field and out to plugin badges. Anything outside the
# Legacy alias: older manifests labelled note-chart-derived # enum (or the wrong type) falls back to "xml" — the
# lyrics with the source format's name; normalise it. # back-compat default — instead of being stringified and
_LYRICS_SOURCE_ALIASES = {"sng": "notechart"} # trusted.
# Post-alias values only: `whisperx` is normalised to
# `transcribed` before the membership check below, so (like
# `sng`) it is intentionally absent from this set.
_ALLOWED_LYRICS_SOURCES = {
"xml", "notechart", "user",
"authored", "transcribed",
}
# Legacy aliases: older manifests labelled note-chart-derived
# lyrics with the source format's name, and the WhisperX
# fallback with the engine name — normalise both to the
# spec vocabulary the badges now expect.
_LYRICS_SOURCE_ALIASES = {"sng": "notechart", "whisperx": "transcribed"}
raw_source = manifest.get("lyrics_source") raw_source = manifest.get("lyrics_source")
if isinstance(raw_source, str): if isinstance(raw_source, str):
raw_source = _LYRICS_SOURCE_ALIASES.get(raw_source, raw_source) raw_source = _LYRICS_SOURCE_ALIASES.get(raw_source, raw_source)