From 5e6d9170d7b132bf20656a19d89c4f371982d1ce Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Sat, 4 Jan 2025 12:20:23 +0100 Subject: [PATCH] Fix lastgenre "count" issue When original genres were kept (keep_existing option), the final genre count was "off". The reason was that reducing genres to that count is handled in _resolve_genre which wasn't run. - This fixes it by ensuring a run of _resolve_genre in _combine_and_label_genres. - There is a small caveat though: New genres have been run through _resolve_genres already. When they are combined with the old ones, they run through it again. Let's take this into account for now and hope performance doesn't suffer too much. --- beetsplug/lastgenre/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index 04cdd5905..bebf8c578 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -370,8 +370,11 @@ class LastGenrePlugin(plugins.BeetsPlugin): if new_genres and keep_genres: split_genres = new_genres.split(separator) combined_genres = deduplicate(keep_genres + split_genres) - return separator.join(combined_genres), f"keep + {log_label}" + # If we combine old and new, run through _resolve_genres (again). + resolved_genres = self._resolve_genres(combined_genres) + return resolved_genres, f"keep + {log_label}" if new_genres: + # New genres ran through _resolve_genres already. return new_genres, log_label return None, log_label