musicbrainz: fix release type (#6299)

- Update the MusicBrainz integration to read the release group's
canonical `'primary-type'` field instead of the legacy `'type'` field
when deriving `info.albumtype`.

Noticed that `albumtype` was missing from the metadata when I did some
imports in my library.
This commit is contained in:
Šarūnas Nejus 2026-01-31 18:11:21 +00:00 committed by GitHub
commit 0cde654ffe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 7 deletions

View file

@ -607,12 +607,8 @@ class MusicBrainzPlugin(MusicBrainzAPIMixin, MetadataSourcePlugin):
if release.get("disambiguation"):
info.albumdisambig = release.get("disambiguation")
# Get the "classic" Release type. This data comes from a legacy API
# feature before MusicBrainz supported multiple release types.
if "type" in release["release-group"]:
reltype = release["release-group"]["type"]
if reltype:
info.albumtype = reltype.lower()
if reltype := release["release-group"].get("primary-type"):
info.albumtype = reltype.lower()
# Set the new-style "primary" and "secondary" release types.
albumtypes = []

View file

@ -52,7 +52,7 @@ class MBAlbumInfoTest(MusicBrainzTestCase):
"asin": "ALBUM ASIN",
"disambiguation": "R_DISAMBIGUATION",
"release-group": {
"type": "Album",
"primary-type": "Album",
"first-release-date": date_str,
"id": "RELEASE GROUP ID",
"disambiguation": "RG_DISAMBIGUATION",