Skip to content

Commit

Permalink
Merge pull request #10 from WorldObservationLog/main
Browse files Browse the repository at this point in the history
fix: adapt lrc two digits ms standard
  • Loading branch information
zhaarey authored Apr 25, 2024
2 parents 1032b73 + c50b59c commit 7cfde4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions main_atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1290,7 +1290,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
Expand Down
5 changes: 3 additions & 2 deletions main_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1290,7 +1290,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
Expand Down

0 comments on commit 7cfde4b

Please sign in to comment.