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.
This commit is contained in:
J0J0 Todos 2025-03-27 23:02:57 +01:00
parent 2b276e07f1
commit edd366e766

View file

@ -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))
):
if isinstance(obj, library.Item) and "track" in self.sources:
if new_genres := self.fetch_track_genre(obj):
label = "track"
elif "album" in self.sources and (
new_genres := self.fetch_album_genre(obj)
):
if not new_genres and "album" in self.sources:
if new_genres := self.fetch_album_genre(obj):
label = "album"
elif "artist" in self.sources:
if not new_genres and "artist" in self.sources:
new_genres = None
if isinstance(obj, library.Item):
new_genres = self.fetch_artist_genre(obj)