答案 0 :(得分:0)
但这对于id3v2来说还不够,如show in this commit,它必须修剪这些空字符。
请参阅cutset := string(rune(0))
和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)