diff --git a/scripts/slim-embedded-art.py b/scripts/slim-embedded-art.py index bafc363..d4e3fed 100755 --- a/scripts/slim-embedded-art.py +++ b/scripts/slim-embedded-art.py @@ -43,6 +43,11 @@ PROCESS_OVER = 100_000 # McCourt's "Angela's Ashes" - 1.5 MB of memoir in an Eels track's USLT, courtesy of some tagger # malfunction - and AVPlayer pages through ALL of it before the first audio frame, art or not. LYRICS_SANE = 50_000 +# The last 47 oversized files held no big art and no big lyrics - just PADDING: empty space some +# tagger reserved for future edits, up to 478 KB of it against 39 bytes of actual frames (the DJ +# Sets tree, 2026-08-29). The player pages through padding like anything else, so a tag this far +# past its content gets rewritten (the save already zeroes padding). +TAG_SANE = 200_000 def audio_region_hash(path, offset=None): @@ -125,13 +130,15 @@ def process(path, apply): pics = pictures(tag) total = sum(len(p.data) for p in pics) junk_lyrics = [f for f in tag.getall("USLT") if len(f.text or "") > LYRICS_SANE] - if total <= PROCESS_OVER and not junk_lyrics: + bloated = tag.size > TAG_SANE + if total <= PROCESS_OVER and not junk_lyrics and not bloated: return None largest = max(pics, key=lambda p: len(p.data)) if pics else None if not apply: parts = [] if total > PROCESS_OVER: parts.append(f"{total // 1024} KB of art") if junk_lyrics: parts.append(f"{sum(len(f.text) for f in junk_lyrics) // 1024} KB of junk lyrics") + if not parts and bloated: parts.append(f"{tag.size // 1024} KB tag of mostly padding") return "would slim " + " + ".join(parts) before = audio_region_hash(path)