From edd366e766f276c71c0c567d477b0dd3880b72b0 Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Thu, 27 Mar 2025 23:02:57 +0100 Subject: [PATCH] lastgenre: Fix album not falling back to artist stage which was the usual behaviour in lastgenre ever since and it should be kept that way. Also refactor "if track" to use a similar notation for overall code readability. --- beetsplug/lastgenre/__init__.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index ec27456f9..a8c8e7c04 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -357,6 +357,7 @@ class LastGenrePlugin(plugins.BeetsPlugin): and the whitelist feature was disabled. """ keep_genres = [] + new_genres = [] label = "" genres = self._get_existing_genres(obj) @@ -374,17 +375,15 @@ class LastGenrePlugin(plugins.BeetsPlugin): # Run through stages: track, album, artist, # album artist, or most popular track genre. - if ( - isinstance(obj, library.Item) - and "track" in self.sources - and (new_genres := self.fetch_track_genre(obj)) - ): - label = "track" - elif "album" in self.sources and ( - new_genres := self.fetch_album_genre(obj) - ): - label = "album" - elif "artist" in self.sources: + if isinstance(obj, library.Item) and "track" in self.sources: + if new_genres := self.fetch_track_genre(obj): + label = "track" + + if not new_genres and "album" in self.sources: + if new_genres := self.fetch_album_genre(obj): + label = "album" + + if not new_genres and "artist" in self.sources: new_genres = None if isinstance(obj, library.Item): new_genres = self.fetch_artist_genre(obj)