cleanLRC before embeding the lyric

This commit is contained in:
tramhao 2021-03-03 00:32:07 +08:00
parent 5122ed3213
commit 40c5d1a316
2 changed files with 2 additions and 0 deletions

View File

@ -136,6 +136,7 @@ func makeTime(h int, m int, s int, ms int) time.Time {
// cleanLRC clean the string download
func cleanLRC(s string) (cleanLyric string) {
// Clean ' to '
s = strings.ToValidUTF8(s, " ")
s = strings.Replace(s, "'", "'", -1)
// It's wierd that sometimes there are two ajacent ''.
// Replace it anyway

View File

@ -99,6 +99,7 @@ func GetLyricChinese(lyricID string, serviceProvider string) (string, error) {
// file.Close()
// }
if looksLikeLRC(lyric) {
lyric = cleanLRC(lyric)
return lyric, nil
}
return "", fmt.Errorf("lyric not compatible")