Skip to content

Commit

Permalink
Merge pull request #601 from Cephian/master
Browse files Browse the repository at this point in the history
Add frame header bytes to MP3 score
  • Loading branch information
phw authored Mar 22, 2023
2 parents 2115107 + 7c1e706 commit cef3e3e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mutagen/mp3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,11 @@ def mime(self):
def score(filename, fileobj, header_data):
filename = filename.lower()

return (header_data.startswith(b"ID3") * 2 +
return ((header_data.startswith(b"ID3") or
header_data.startswith(b'\xFF\xF2') or
header_data.startswith(b'\xFF\xF3') or
header_data.startswith(b'\xFF\xFA') or
header_data.startswith(b'\xFF\xFB')) * 2 +
endswith(filename, b".mp3") +
endswith(filename, b".mp2") + endswith(filename, b".mpg") +
endswith(filename, b".mpeg"))
Expand Down
Binary file added tests/data/no-tags.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions tests/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ def test_dict(self):
os.path.join(DATA_DIR, "bad-xing.mp3"),
os.path.join(DATA_DIR, "xing.mp3"),
os.path.join(DATA_DIR, "silence-44-s.mp3"),
os.path.join(DATA_DIR, "no-tags.mp3"),
],
Musepack: [
os.path.join(DATA_DIR, "click.mpc"),
Expand Down

0 comments on commit cef3e3e

Please sign in to comment.