From 10d13992e66d9eeb238deafc2c0a4a2576e25522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Mon, 23 Feb 2026 04:51:41 +0000 Subject: [PATCH] Dedupe genres parsing in beatport --- beetsplug/beatport.py | 14 +++++--------- test/plugins/test_beatport.py | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/beetsplug/beatport.py b/beetsplug/beatport.py index 3368825b8..aa0693541 100644 --- a/beetsplug/beatport.py +++ b/beetsplug/beatport.py @@ -234,9 +234,11 @@ class BeatportObject: ) if "artists" in data: self.artists = [(x["id"], str(x["name"])) for x in data["artists"]] - if "genres" in data: - genre_list = [str(x["name"]) for x in data["genres"]] - self.genres = unique_list(genre_list) + + self.genres = unique_list( + x["name"] + for x in (*data.get("subGenres", []), *data.get("genres", [])) + ) def artists_str(self) -> str | None: if self.artists is not None: @@ -305,12 +307,6 @@ class BeatportTrack(BeatportObject): self.bpm = data.get("bpm") self.initial_key = str((data.get("key") or {}).get("shortName")) - # Extract genres list from subGenres or genres - self.genres = unique_list( - str(x.get("name")) - for x in data.get("subGenres") or data.get("genres") or [] - ) - class BeatportPlugin(MetadataSourcePlugin): _client: BeatportClient | None = None diff --git a/test/plugins/test_beatport.py b/test/plugins/test_beatport.py index 442f80037..96386d8b6 100644 --- a/test/plugins/test_beatport.py +++ b/test/plugins/test_beatport.py @@ -474,7 +474,7 @@ class BeatportTest(BeetsTestCase): item.year = 2016 item.comp = False item.label_name = "Gravitas Recordings" - item.genres = ["Glitch Hop"] + item.genres = ["Glitch Hop", "Breaks"] item.year = 2016 item.month = 4 item.day = 11