From ecf81eee888bb42e3cf090edd569b775a6c2bf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Pe=C3=B1a?= Date: Sat, 3 Sep 2022 04:54:43 +0000 Subject: [PATCH] Fixes wrong metadata field used in VA album serialization --- api/funkwhale_api/music/metadata.py | 13 ++++++++++--- changes/changelog.d/1201.bugfix | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 changes/changelog.d/1201.bugfix diff --git a/api/funkwhale_api/music/metadata.py b/api/funkwhale_api/music/metadata.py index 9d19e1557..89f02a6ac 100644 --- a/api/funkwhale_api/music/metadata.py +++ b/api/funkwhale_api/music/metadata.py @@ -480,8 +480,8 @@ class ArtistField(serializers.Field): def get_value(self, data): if self.for_album: keys = [ - ("artists", "artists"), - ("names", "album_artist"), + ("artists", "album_artist"), + ("names", "artists"), ("mbids", "musicbrainz_albumartistid"), ] else: @@ -525,7 +525,14 @@ class ArtistField(serializers.Field): if separator in data["artists"]: names = [n.strip() for n in data["artists"].split(separator)] break - if not names: + # corner case: 'album artist' field with only one artist but multiple names in 'artits' field + if ( + not names + and data.get("names", None) + and any(separator in data["names"] for separator in separators) + ): + names = [n.strip() for n in data["names"].split(separators[0])] + elif not names: names = [data["artists"]] elif used_separator and mbids: names = [n.strip() for n in data["names"].split(used_separator)] diff --git a/changes/changelog.d/1201.bugfix b/changes/changelog.d/1201.bugfix new file mode 100644 index 000000000..93d1ba440 --- /dev/null +++ b/changes/changelog.d/1201.bugfix @@ -0,0 +1 @@ +Fixed metadata handling for Various Artists albums (#1201)