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.
This commit is contained in:
J0J0 Todos 2025-01-13 07:58:46 +01:00
parent f698f21a28
commit f16e671ff6

View file

@ -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: