fix ttml match
This commit is contained in:
parent
bafb3ee310
commit
337d04b813
@ -1252,15 +1252,20 @@ func conventTTMLToLRC(ttml string) (string, error) {
|
||||
var lrcLines []string
|
||||
for _, item := range parsedTTML.FindElement("tt").FindElement("body").ChildElements() {
|
||||
for _, lyric := range item.ChildElements() {
|
||||
var m, s, ms int
|
||||
var h, m, s, ms int
|
||||
if lyric.SelectAttr("begin") == nil {
|
||||
return "", errors.New("no synchronised lyrics")
|
||||
}
|
||||
if strings.Contains(lyric.SelectAttr("begin").Value, ":") {
|
||||
_, err = fmt.Sscanf(lyric.SelectAttr("begin").Value, "%d:%d:%d.%d", &h, &m, &s, &ms)
|
||||
if err != nil {
|
||||
_, err = fmt.Sscanf(lyric.SelectAttr("begin").Value, "%d:%d.%d", &m, &s, &ms)
|
||||
} else {
|
||||
h = 0
|
||||
}
|
||||
if err != nil {
|
||||
_, err = fmt.Sscanf(lyric.SelectAttr("begin").Value, "%d.%d", &s, &ms)
|
||||
m = 0
|
||||
h, m = 0, 0
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -1279,6 +1284,7 @@ func conventTTMLToLRC(ttml string) (string, error) {
|
||||
} else {
|
||||
text = lyric.SelectAttr("text").Value
|
||||
}
|
||||
m += h * 60
|
||||
lrcLines = append(lrcLines, fmt.Sprintf("[%02d:%02d.%03d]%s", m, s, ms, text))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user