From f16e671ff613c4ea8801c75ea336366f03816142 Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Mon, 13 Jan 2025 07:58:46 +0100 Subject: [PATCH] Simplify _get_genre keep_existing conditional - If the keep_existing option is set, just remember everything for now. - Dedup happening later on via _combine... _resolve_genres... - Even knowing if whitelist or not is not important at this point. --- beetsplug/lastgenre/__init__.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index aebde9b06..248242df1 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -388,19 +388,18 @@ class LastGenrePlugin(plugins.BeetsPlugin): genres = self._get_existing_genres(obj, separator) if genres and not self.config["force"]: # Without force we don't touch pre-populated tags and return early - # with the original contents. We format back to string tough. + # with the original contents. We deduplicate and format back to + # string though. keep_genres = self._dedup_genres(genres) return separator.join(keep_genres), "keep" if self.config["force"]: # Simply forcing doesn't keep any. keep_genres = [] - # keep_existing remembers, according to the whitelist setting, - # any or just allowed genres. - if self.config["keep_existing"] and self.config["whitelist"]: - keep_genres = self._dedup_genres(genres, whitelist_only=True) - elif self.config["keep_existing"]: - keep_genres = self._dedup_genres(genres) + # Remember existing genres if required. Whitelist validation is + # handled later in _resolve_genres. + if self.config["keep_existing"]: + keep_genres = [g.lower() for g in genres] # Track genre (for Items only). if isinstance(obj, library.Item) and "track" in self.sources: