1. Robert Lowry
  2. go-id3

Commits

Robert Lowry  committed 3ea1d16

moved simple check for ID3 header into Read(..) function

  • Participants
  • Parent commits b381337
  • Branches master

Comments (0)

Files changed (1)

File id3/id3.go

View file
  • Ignore whitespace
 	Length string
 }
 
-// Parse the input for ID3 information. Returns nil if parsing failed or the
+// Parse stream for ID3 information. Returns nil if parsing failed or the
 // input didn't contain ID3 information.
+// NOTE: ID3v1 and appended ID3v2.x are not supported without the ability
+// to seek in the input.
 func Read(reader io.Reader) (*File, error) {
 	buf := bufio.NewReader(reader)
-	if !isID3Tag(buf) {
+	data, err := buf.Peek(3)
+	if err != nil || len(data) < 3 || string(data) != "ID3" {
 		return nil, fmt.Errorf("no id3 tags")
 	}
 	tags, err := parseID3v2File(buf)
 	}
 	return tags, nil
 }
-
-func isID3Tag(reader *bufio.Reader) bool {
-	data, err := reader.Peek(3)
-	if len(data) < 3 || err != nil {
-		return false
-	}
-	return data[0] == 'I' && data[1] == 'D' && data[2] == '3'
-}
-