From 7ff06df17cfef38c0029b5faeb193d2569220d16 Mon Sep 17 00:00:00 2001 From: J0J0 Todos <2733783+JOJ0@users.noreply.github.com> Date: Tue, 21 Jan 2025 12:05:17 +0100 Subject: [PATCH] Simplify _get_existing_genres() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Šarūnas Nejus --- beetsplug/lastgenre/__init__.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index 07bc3022d..5da907996 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -297,15 +297,12 @@ class LastGenrePlugin(plugins.BeetsPlugin): def _get_existing_genres(self, obj: Union[Album, Item]) -> list[str]: """Return a list of genres for this Item or Album.""" - separator = self.config["separator"].get() if isinstance(obj, library.Item): - item_genre = obj.get("genre", with_album=False).split(separator) + genre_str = obj.get("genre", with_album=False) else: - item_genre = obj.get("genre").split(separator) + genre_str = obj.get("genre") - if any(item_genre): - return item_genre - return [] + return genre_str.split(self.config["separator"].get()) def _polish_existing_genres(self, genres: list[str]) -> str: """Return a separator delimited string of deduplicated and formatted