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 关注
- 118 浏览
添加回答
举报