Delete the SYLT frame by its HashKey - #112
Open
stefanvanburen wants to merge 1 commit into
Open
stefanvanburen wants to merge 1 commit into
stefanvanburen wants to merge 1 commit into
Conversation
Mutagen stores SYLT under the HashKey "SYLT::XXX", but
MP3SYLTStorageStyle inherited a delete() that looked for a bare "SYLT"
key, so it never matched. Deleting the field was a silent no-op:
mf = MediaFile("x.mp3") # has a SYLT frame
del mf.synced_lyrics # or update({"synced_lyrics": None})
mf.save() # SYLT::XXX still present
The class already had this right in store(), which clears with
delall("SYLT"); only the delete path was missing. Every sibling style
whose frames carry a non-bare HashKey overrides delete for the same
reason -- MP3DescStorageStyle deletes via frame.HashKey, and
MP3ImageStorageStyle uses delall.
Assignment-clearing (mf.synced_lyrics = None) went through store() and
so already worked, which is why the existing test_clear passed.
stefanvanburen
added a commit
to stefanvanburen/dotfiles
that referenced
this pull request
Sep 8, 2026
LRClib serves timestamped lyrics, but beets writes the LRC text *including* timestamps into the ordinary `lyrics` field and only passes the parsed timing to SYLT on top. SYLT is an mp3-only MediaField, and none of the players here read it: Cog exposes only `unsyncedlyrics`, Swinsian keeps a single plain `lyrics TEXT` column, Music.app hands back the raw timestamped string, and VLC and IINA have no lyrics UI at all. So turning it on only prefixes every line with "[00:20.53] ". It is also close to a one-way door, since beets can write SYLT but not delete it (beetbox/mediafile#112). Record all of that next to the two options rather than rediscovering it.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
synced_lyricscan be written but not deleted. Mutagen stores the SYLT frame under the HashKeySYLT::XXX, whileMP3SYLTStorageStyleinherits adelete()that looks for a bareSYLTkey, so it never matches and the deletion is a silent no-op.Repro
MediaFile.update()is affected too, since it callsdelattrfor any key whose value isNone— so its documented "if a key has the valueNone, the corresponding property is deleted" doesn't hold for this field.Why it was missed
The class already gets this right in
store(), which clears withdelall("SYLT"); only the delete path was missing. Assignment-clearing (mf.synced_lyrics = None) routes throughstore(), which is why the existingtest_clearpasses and this went unnoticed.Sibling styles whose frames carry a non-bare HashKey all override
deletefor the same reason —MP3DescStorageStyle(USLT) deletes viaframe.HashKey, andMP3ImageStorageStyle(APIC) usesdelall.Fix
Three lines, mirroring
MP3ImageStorageStyle:Tests
Four added to
TestSyncedLyrics, all of which fail without the fix and pass with it:test_delete[mp3],test_delete[aiff]—delremoves the frametest_update_with_none_clears—update({"synced_lyrics": None})removes ittest_delete_leaves_plain_lyrics— deleting SYLT doesn't disturb USLTFull suite is 491 passed, 1 failed:
OpusTest::test_read_audio_properties, which fails identically on unmodifiedmaster(#109).ruff checkandruff format --checkare clean.How I hit it
Turning on beets'
lyrics.syncedand then turning it back off. USLT reverts, but every MP3 keeps a stale SYLT frame that beets has no way to remove.