Skip to content

Commit f886e81

Browse files
authored
MPEG Audio Scanner (aka MP3 Scanner) (#122)
1 parent 971c780 commit f886e81

16 files changed

+1610
-243
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,7 @@ media
143143
static
144144

145145
.idea/
146+
147+
# Ignore VS Code related files and folders
148+
.vscode
149+
*.code-workspace

puremagic/magic_data.json

Lines changed: 415 additions & 241 deletions
Large diffs are not rendered by default.

puremagic/main.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@
2222
import puremagic
2323

2424
if os.getenv("PUREMAGIC_DEEPSCAN") != "0":
25-
from puremagic.scanners import zip_scanner, pdf_scanner, text_scanner, json_scanner, python_scanner, sndhdr_scanner
25+
from puremagic.scanners import (
26+
zip_scanner,
27+
pdf_scanner,
28+
text_scanner,
29+
json_scanner,
30+
python_scanner,
31+
sndhdr_scanner,
32+
mpeg_audio_scanner,
33+
)
2634

2735
__author__ = "Chris Griffith"
2836
__version__ = "2.0.0b5"
@@ -398,6 +406,10 @@ def single_deep_scan(
398406
result = sndhdr_scanner.main(filename, head, foot)
399407
if result and result.confidence > confidence:
400408
return result
409+
case mpeg_bytes if mpeg_bytes in mpeg_audio_scanner.mpeg_audio_signatures:
410+
result = mpeg_audio_scanner.main(filename, head, foot)
411+
if result and result.confidence > confidence:
412+
return result
401413

402414
# The first match wins
403415
for scanner in (pdf_scanner, python_scanner, json_scanner):
@@ -519,7 +531,7 @@ def command_line_entry(*args):
519531
print(f"Total Possible Matches: {len(matches)}")
520532
for i, result in enumerate(matches):
521533
if i == 0:
522-
print("\n\tBest Match")
534+
print("\n\tDeepscan Match" if int(result.confidence == 1) else "\n\tBest Match")
523535
else:
524536
print(f"\tAlternative Match #{i}")
525537
print(f"\tName: {result.name}")

0 commit comments

Comments
 (0)