mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-14 22:28:41 +01:00
feat(plugins): content-sniff plugin lyrics for all formats
Replace model.ToLyrics (LRC/plain only) with model.ParseEmbedded so plugin responses are content-sniffed for TTML, SRT, YAML, LRC, and plain text. ParseEmbedded returns a LyricList, so the loop now flattens multiple tracks per response entry. The test-lyrics WASM plugin gains a "ttml" format mode (configured via pdk.GetConfig) that returns a minimal TTML document; rebuilt with the standard Go wasip1 toolchain (GOOS=wasip1 GOARCH=wasm). A new Ginkgo test asserts Synced==true and the exact cue value, which the old plain-text path could not produce. GetLyrics doc comment updated to reflect content-sniffing; a later task will retarget it to ParseLyrics once that function is introduced.
This commit is contained in:
parent
7559e20d41
commit
0ec7a818fb
3 changed files with 45 additions and 5 deletions
18
plugins/testdata/test-lyrics/main.go
vendored
18
plugins/testdata/test-lyrics/main.go
vendored
|
|
@ -21,6 +21,24 @@ func (t *testLyrics) GetLyrics(input lyrics.GetLyricsRequest) (lyrics.GetLyricsR
|
|||
return lyrics.GetLyricsResponse{}, fmt.Errorf("%s", errMsg)
|
||||
}
|
||||
|
||||
// Return a minimal TTML document to exercise content-sniffing for rich formats.
|
||||
format, hasFormat := pdk.GetConfig("format")
|
||||
if hasFormat && format == "ttml" {
|
||||
const ttml = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tt xmlns="http://www.w3.org/ns/ttml">
|
||||
<body xml:lang="eng">
|
||||
<div>
|
||||
<p begin="00:00.000" end="00:01.000">plugin ttml line</p>
|
||||
</div>
|
||||
</body>
|
||||
</tt>`
|
||||
return lyrics.GetLyricsResponse{
|
||||
Lyrics: []lyrics.LyricsText{
|
||||
{Lang: "eng", Text: ttml},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Check if we should omit language (to test default language handling)
|
||||
noLang, hasNoLang := pdk.GetConfig("no_lang")
|
||||
lang := "eng"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue