slim-embedded-art: rewrite tags that are mostly padding

The final 47 oversized files held no big art and no big lyrics - just
empty reserved space, up to 478 KB of padding against 39 bytes of
frames, all in the DJ Sets tree. The player pages through padding like
anything else. A tag past 200 KB total is rewritten regardless of what
fills it; the save already zeroes padding.
This commit is contained in:
2026-08-29 08:39:14 +01:00
parent f17a88be9a
commit de8949efa7
+8 -1
View File
@@ -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)