Support for the UFID tag

This commit is contained in:
Xavier Henner 2015-05-22 01:20:55 +02:00 committed by David Howden
parent 45d987ac1d
commit eef1ffcbbd
2 changed files with 27 additions and 0 deletions

View File

@ -225,6 +225,13 @@ func readID3v2Frames(r io.Reader, h *ID3v2Header) (map[string]interface{}, error
}
result[rawName] = txt
case name == "UFID" || name == "UFI":
t, err := readUfid(b)
if err != nil {
return nil, err
}
result[rawName] = t
case name == "WXXX" || name == "WXX":
t, err := readTextWithDescrFrame(b, false, false) // no lang, no enc
if err != nil {

View File

@ -195,6 +195,26 @@ func readTextWithDescrFrame(b []byte, hasLang bool, encoded bool) (*Comm, error)
}, nil
}
// UFID is composed of a provider (frequently an URL and a binary identifier)
// The identifier can be a text (Musicbrainz use texts, but not necessary)
type Ufid struct {
Provider string
Identifier []byte
}
func (u Ufid) String() string {
return fmt.Sprintf("%v (%v)", u.Provider, string(u.Identifier))
}
func readUfid(b []byte) (*Ufid, error) {
result := bytes.SplitN(b, []byte{0}, 2)
return &Ufid{
Provider: string(result[0]),
Identifier: result[1],
}, nil
}
var pictureTypes = map[byte]string{
0x00: "Other",
0x01: "32x32 pixels 'file icon' (PNG only)",