Skip to content

Commit

Permalink
fix: fix mp3 detection
Browse files Browse the repository at this point in the history
  • Loading branch information
ttys3 committed Mar 3, 2023
1 parent cfcd7d0 commit 643487e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion matchers/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ func Midi(buf []byte) bool {
buf[2] == 0x68 && buf[3] == 0x64
}

// ref https://github.com/mirror/jdownloader/blob/c174969108dcc71df6d7b77f5b649efbca1a5e7a/src/org/jdownloader/extensions/extraction/mime.type#L13
// https://github.com/h2non/filetype/issues/10#issuecomment-232439340
func Mp3(buf []byte) bool {
return len(buf) > 2 &&
((buf[0] == 0x49 && buf[1] == 0x44 && buf[2] == 0x33) ||
(buf[0] == 0xFF && buf[1] == 0xfb))
(buf[0] == 0xFF && buf[1] == 0xfb) ||
(buf[0] == 0xFF && buf[1] == 0xfa) ||
(buf[0] == 0xFF && buf[1] == 0xf3))
}

func M4a(buf []byte) bool {
Expand Down

0 comments on commit 643487e

Please sign in to comment.