From c9187b40bda3ebdd2244b05a92466094166b3c8e Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Tue, 21 Jan 2025 12:38:20 +0100 Subject: [PATCH] Don't uselessly split/join early returned genres --- beetsplug/lastgenre/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index fce864c66..d8abd22a1 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -334,15 +334,16 @@ class LastGenrePlugin(plugins.BeetsPlugin): indicates that existing genres were combined with new last.fm genres, while "artist" means only new last.fm genres are included. """ - keep_genres = [] - separator = self.config["separator"].as_str() - genres = self._get_existing_genres(obj) - if genres and not self.config["force"]: + if not self.config["force"]: # Without force pre-populated tags are returned as-is. - return separator.join(genres), "keep" + if isinstance(obj, library.Item): + return obj.get("genre", with_album=False), "keep, no-force" + return obj.get("genre"), "keep, no-force" if self.config["force"]: + genres = self._get_existing_genres(obj) + keep_genres = [] # Force doesn't keep any unless keep_existing is set. # Whitelist validation is handled in _resolve_genres. if self.config["keep_existing"]: