mutagen icon indicating copy to clipboard operation
mutagen copied to clipboard

Fix handling of albumartistsort as TSO2 and TXXX:ALBUMARTISTSORT in EasyID3

Open antlarr opened this issue 8 months ago • 0 comments

albumartistsort is duplicated as a Text key in easyid3.py#L492 and as a TXXX key in easyid3.py#L533 thus replacing the previous registration.

Because of that, before this change, loading a file with EasyID3 that has a TSO2 frame doesn't make it available by accessing albumartistsort.

Even if TSO2 is not an official tag it seems to be generally supported, and since picard writes TSO2 frames for "album artist sort order", I think it's better to give priority to TSO2 over TXXX:ALBUMARTISTSORT.

I also added a test that fails with the current code and runs successfully after the fix is applied to make sure it doesn't break in the future again.

Actually, we can't just remove TXXX:ALBUMARTISTSORT registration, since that would break reading such frames in files already written as that. So I've added a third commit that falls back to getting the TXXX:ALBUMARTISTSORT value if TSO2 isn't found, deletes both TSO2 and TXXX:ALBUMARTISTSORT frames when deleting albumartistsort and added more tests for those cases.

I'm aware this third commit makes the code a bit more complex, but I've tried to make it as generic as possible just in case other fallback frames need to be added in the future for some other key.

antlarr avatar Jun 14 '24 10:06 antlarr