Compare commits

..

2 Commits

Author SHA1 Message Date
ZHAAREY 453fcd7a5c
Merge pull request #29 from itouakirai/patch-3 1 month ago
itouakirai 1656721cb9
修复逐字歌词行开头为空格的问题 1 month ago
  1. 5
      main.go

@ -1856,11 +1856,15 @@ func conventSyllableTTMLToLRC(ttml string) (string, error) {
for _, div := range parsedTTML.FindElement("tt").FindElement("body").FindElements("div") { for _, div := range parsedTTML.FindElement("tt").FindElement("body").FindElements("div") {
for _, item := range div.ChildElements() { for _, item := range div.ChildElements() {
var lrcSyllables []string var lrcSyllables []string
var i int = 0
for _, lyrics := range item.Child { for _, lyrics := range item.Child {
if _, ok := lyrics.(*etree.CharData); ok { if _, ok := lyrics.(*etree.CharData); ok {
if i > 0 {
lrcSyllables = append(lrcSyllables, " ") lrcSyllables = append(lrcSyllables, " ")
continue continue
} }
continue
}
lyric := lyrics.(*etree.Element) lyric := lyrics.(*etree.Element)
if lyric.SelectAttr("begin") == nil { if lyric.SelectAttr("begin") == nil {
continue continue
@ -1884,6 +1888,7 @@ func conventSyllableTTMLToLRC(ttml string) (string, error) {
text = lyric.SelectAttr("text").Value text = lyric.SelectAttr("text").Value
} }
lrcSyllables = append(lrcSyllables, fmt.Sprintf("%s%s", beginTime, text)) lrcSyllables = append(lrcSyllables, fmt.Sprintf("%s%s", beginTime, text))
i += 1
} }
endTime, err := parseTime(item.SelectAttr("end").Value) endTime, err := parseTime(item.SelectAttr("end").Value)
if err != nil { if err != nil {

Loading…
Cancel
Save