1 回答

TA貢獻1995條經驗 獲得超2個贊
這是id3-go 中的當前問題:PR 8針對 id3v1 修復了它
但這對于 id3v2 來說還不夠,如本次提交所示,它確實必須修剪那些空字符。請參閱cutset := string(rune(0)), 和 of的使用,TrimRight(s string, cutset string)例如strings.TrimRight(fd.Title(), cutset):
fd, err := id3.Open(path)
if err != nil {
item.Title = f.Name()
} else {
defer fd.Close()
cutset := string(rune(0))
title := strings.TrimRight(fd.Title(), cutset)
author := strings.TrimRight(fd.Artist(), cutset)
if len(title) > 0 {
item.Title = title
} else {
item.Title = author
if len(author) > 0 {
item.Title += " - "
}
item.Title += strings.TrimRight(f.Name(), cutset)
}
item.Subtitle = author
tcon := fd.Frame("TCON")
if tcon != nil {
item.Categories = append(item.Categories, Text{Value: strings.TrimRight(tcon.String(), cutset)})
}
item.PubDate = strings.TrimRight(formatYear(fd.Year()), cutset)
- 1 回答
- 0 關注
- 141 瀏覽
添加回答
舉報