mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-15 13:57:09 +02:00
refactor(lyrics): move test-only parseTTML/parseSRT wrappers to test files
These zero-arg wrappers (defaulting lang to "xxx") had no production callers after the consolidation — only the format tests used them. Move each beside its tests so the production files carry no test-only code.
This commit is contained in:
parent
fd700f8d8a
commit
ba2ed28ef7
4 changed files with 10 additions and 8 deletions
|
|
@ -14,10 +14,6 @@ var (
|
|||
srtBlockSeparatorRegex = regexp.MustCompile(`\n\s*\n`)
|
||||
)
|
||||
|
||||
func parseSRT(contents []byte) (LyricList, error) {
|
||||
return parseSRTWithLanguage("xxx", contents)
|
||||
}
|
||||
|
||||
func parseSRTWithLanguage(language string, contents []byte) (LyricList, error) {
|
||||
raw := strings.ReplaceAll(string(contents), "\r\n", "\n")
|
||||
raw = strings.ReplaceAll(raw, "\r", "\n")
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import (
|
|||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
// parseSRT parses with the default placeholder language, for test ergonomics.
|
||||
func parseSRT(contents []byte) (LyricList, error) {
|
||||
return parseSRTWithLanguage("xxx", contents)
|
||||
}
|
||||
|
||||
var _ = Describe("parseSRT", func() {
|
||||
It("parses SRT blocks with the default language", func() {
|
||||
content := []byte("1\n00:00:01,000 --> 00:00:02,000\nFirst subtitle\n\n2\n00:00:03,000 --> 00:00:04,000\nSecond subtitle")
|
||||
|
|
|
|||
|
|
@ -102,10 +102,6 @@ type ttmlParser struct {
|
|||
metadataSeq int
|
||||
}
|
||||
|
||||
func parseTTML(contents []byte) (LyricList, error) {
|
||||
return parseTTMLWithDefaultLang("xxx", contents)
|
||||
}
|
||||
|
||||
func isTTMLDocument(text string) bool {
|
||||
decoder := xml.NewDecoder(strings.NewReader(strings.TrimSpace(text)))
|
||||
for {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import (
|
|||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
// parseTTML parses with the default placeholder language, for test ergonomics.
|
||||
func parseTTML(contents []byte) (LyricList, error) {
|
||||
return parseTTMLWithDefaultLang("xxx", contents)
|
||||
}
|
||||
|
||||
var _ = Describe("parseTTML", func() {
|
||||
Describe("Multi-language and timing", func() {
|
||||
It("should parse multiple language divs with inherited offsets and frame/tick timing", func() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue