Fix artist name splitting with semicolons and Vorbis multi-field handling#3390
Fix artist name splitting with semicolons and Vorbis multi-field handling#3390
Conversation
OzGav
commented
Mar 14, 2026
- music_assistant/helpers/tags.py:
- Fixed artists and album_artists properties to not split on semicolons when values are already in a list (multiple ARTIST fields from Vorbis)
- Added MB ID count check for singular ARTIST/ALBUMARTIST tags - if count is 1, don't split even on semicolons
- Added warning in _parse_vorbis_artist_tags() for non-standard ARTISTS/ALBUMARTISTS tags in Vorbis files
- Added proper comments with spec references
- tests/core/test_tags.py:
- Added test_vorbis_multiple_artist_fields_semicolon_in_name - mock test for multiple ARTIST fields with semicolon
- Added test_flac_multiple_artist_fields_semicolon_e2e - end-to-end test with real FLAC file
- Added test_id3_artist_tag_semicolon_single_mbid - test for single ARTIST with semicolon and 1 MB ID
- Added test_id3_artist_tag_semicolon_multiple_mbids - test for ARTIST with semicolon and multiple MB IDs
- Added test_id3_albumartist_tag_semicolon_single_mbid - same for album artist
- tests/fixtures/ArtistWithSemicolon.flac:
- New test fixture with multiple ARTIST fields, one containing ave;new
This comment was marked as outdated.
This comment was marked as outdated.
| if tag := self.tags.get("artists"): | ||
| artists = split_items(tag) | ||
| # Runtime check: mutagen returns list[str] for Vorbis multi-field | ||
| if isinstance(tag, list) and len(tag) > 1: # type: ignore[unreachable] |
There was a problem hiding this comment.
These unreachable mypy warnings actually indicate an incorrect type declaration for self.tags. This should be dict[str, str | list[str]] which will also remove the need for these 'type: ignores'
There was a problem hiding this comment.
The tricky thing is that only the Vorbis parser returns lists (for artists/albumartists) - all other parsers return strings. Changing the type to handle this results in 40+ changes elsewhere. We can't normalize to semicolon-joined strings because the whole point is that Vorbis multi-field tags are already properly separated without delimiter ambiguity - joining and re-splitting would break artist names containing semicolons. Happy to do the 40+ changes if you think it's worth it