Skip to content

Fix UFID error #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions id3v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,7 @@ func readID3v2Frames(r io.Reader, offset uint, h *id3v2Header) (map[string]inter
result[rawName] = txt

case name == "UFID" || name == "UFI":
t, err := readUFID(b)
if err != nil {
return nil, err
}
t := readUFID(b)
result[rawName] = t

case name == "WXXX" || name == "WXX":
Expand Down
9 changes: 6 additions & 3 deletions id3v2frames.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,19 @@ func (u UFID) String() string {
return fmt.Sprintf("%v (%v)", u.Provider, string(u.Identifier))
}

func readUFID(b []byte) (*UFID, error) {
func readUFID(b []byte) *UFID {
result := bytes.SplitN(b, singleZero, 2)
if len(result) != 2 {
return nil, errors.New("expected to split UFID data into 2 pieces")
// Sometimes the UFID consists of one part, for example: track-5979322WOAF
return &UFID{
Identifier: result[0],
}
}

return &UFID{
Provider: string(result[0]),
Identifier: result[1],
}, nil
}
}

var pictureTypes = map[byte]string{
Expand Down