Skip to content
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

Reading of genre from MP4 'gnre' atom #107

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
15 changes: 15 additions & 0 deletions mp4.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"aART": "album_artist",
"\xa9day": "year",
"\xa9nam": "title",
"gnre": "genreid",
"\xa9gen": "genre",
"trkn": "track",
"\xa9wrt": "composer",
Expand Down Expand Up @@ -183,6 +184,14 @@
return nil
}

if name == "gnre" {
if len(b) < 2 {
return fmt.Errorf("invalid encoding: expected at least %d bytes for genre id, got %d", 2, len(b))
}
m.data[name] = int(b[1])
return nil
}

if contentType == "implicit" {
if name == "covr" {
if bytes.HasPrefix(b, pngHeader) {
Expand Down Expand Up @@ -325,7 +334,13 @@
}

func (m metadataMP4) Genre() string {
if g, ok := m.data["gnre"]; ok {
gid, ok := g.(int); ok && gid > 0 && gid <= len(id3v1Genres) {

Check failure on line 338 in mp4.go

View workflow job for this annotation

GitHub Actions / build

syntax error: unexpected { at end of statement
return id3v1Genres[gid-1]
}
}

return m.getString(atoms.Name("genre"))

Check failure on line 343 in mp4.go

View workflow job for this annotation

GitHub Actions / build

syntax error: non-declaration statement outside function body
}

func (m metadataMP4) Year() int {
Expand Down
Loading