mirror of
https://github.com/navidrome/navidrome.git
synced 2026-07-30 08:46:16 -04:00
refactor(lyrics): consolidate lyrics parsing functions names
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -20,8 +20,8 @@ var lyricFormats = []struct {
|
||||
suffixes []string
|
||||
parse lyricParser
|
||||
}{
|
||||
{[]string{".ttml"}, parseTTMLWithDefaultLang},
|
||||
{[]string{".srt"}, parseSRTWithLanguage},
|
||||
{[]string{".ttml"}, parseTTML},
|
||||
{[]string{".srt"}, parseSRT},
|
||||
{[]string{".yaml", ".yml"}, parseLyricsfile},
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ var (
|
||||
srtBlockSeparatorRegex = regexp.MustCompile(`\n\s*\n`)
|
||||
)
|
||||
|
||||
func parseSRTWithLanguage(language string, contents []byte) (LyricList, error) {
|
||||
func parseSRT(language string, contents []byte) (LyricList, error) {
|
||||
raw := strings.ReplaceAll(string(contents), "\r\n", "\n")
|
||||
raw = strings.ReplaceAll(raw, "\r", "\n")
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
// parseSRT parses with the default placeholder language, for test ergonomics.
|
||||
func parseSRT(contents []byte) (LyricList, error) {
|
||||
return parseSRTWithLanguage("xxx", contents)
|
||||
return parseSRT("xxx", contents)
|
||||
}
|
||||
|
||||
var _ = Describe("parseSRT", func() {
|
||||
|
||||
@@ -115,7 +115,7 @@ func isTTMLDocument(contents []byte) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func parseTTMLWithDefaultLang(defaultLang string, contents []byte) (LyricList, error) {
|
||||
func parseTTML(defaultLang string, contents []byte) (LyricList, error) {
|
||||
contents = xmlEncodingRegex.ReplaceAll(contents, []byte(`<?xml$1encoding="UTF-8"$2?>`))
|
||||
|
||||
// Skip non-TTML content so sniffing doesn't run the full TTML parse on plain
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
// parseTTML parses with the default placeholder language, for test ergonomics.
|
||||
func parseTTML(contents []byte) (LyricList, error) {
|
||||
return parseTTMLWithDefaultLang("xxx", contents)
|
||||
return parseTTML("xxx", contents)
|
||||
}
|
||||
|
||||
var _ = Describe("parseTTML", func() {
|
||||
|
||||
Reference in New Issue
Block a user