fix: adapt lrc two digit ms standard

This commit is contained in:
WorldObservationLog 2024-04-25 22:53:19 +08:00
parent 5b613e4d86
commit 4f272b5ab7
3 changed files with 7 additions and 4 deletions

View File

@ -1233,7 +1233,7 @@ func conventTTMLToLRC(ttml string) (string, error) {
if err != nil {
_, err = fmt.Sscanf(lyric.SelectAttr("begin").Value, "%d:%d.%d", &m, &s, &ms)
h = 0
}
}
} else {
_, err = fmt.Sscanf(lyric.SelectAttr("begin").Value, "%d.%d", &s, &ms)
h, m = 0, 0
@ -1256,7 +1256,8 @@ func conventTTMLToLRC(ttml string) (string, error) {
text = lyric.SelectAttr("text").Value
}
m += h * 60
lrcLines = append(lrcLines, fmt.Sprintf("[%02d:%02d.%03d]%s", m, s, ms, text))
ms = ms / 10
lrcLines = append(lrcLines, fmt.Sprintf("[%02d:%02d.%02d]%s", m, s, ms, text))
}
}
return strings.Join(lrcLines, "\n"), nil

View File

@ -1267,7 +1267,7 @@ func conventTTMLToLRC(ttml string) (string, error) {
if err != nil {
_, err = fmt.Sscanf(lyric.SelectAttr("begin").Value, "%d:%d.%d", &m, &s, &ms)
h = 0
}
}
} else {
_, err = fmt.Sscanf(lyric.SelectAttr("begin").Value, "%d.%d", &s, &ms)
h, m = 0, 0
@ -1290,6 +1290,7 @@ func conventTTMLToLRC(ttml string) (string, error) {
text = lyric.SelectAttr("text").Value
}
m += h * 60
ms = ms / 10
lrcLines = append(lrcLines, fmt.Sprintf("[%02d:%02d.%03d]%s", m, s, ms, text))
}
}

View File

@ -1267,7 +1267,7 @@ func conventTTMLToLRC(ttml string) (string, error) {
if err != nil {
_, err = fmt.Sscanf(lyric.SelectAttr("begin").Value, "%d:%d.%d", &m, &s, &ms)
h = 0
}
}
} else {
_, err = fmt.Sscanf(lyric.SelectAttr("begin").Value, "%d.%d", &s, &ms)
h, m = 0, 0
@ -1290,6 +1290,7 @@ func conventTTMLToLRC(ttml string) (string, error) {
text = lyric.SelectAttr("text").Value
}
m += h * 60
ms = ms / 10
lrcLines = append(lrcLines, fmt.Sprintf("[%02d:%02d.%03d]%s", m, s, ms, text))
}
}