diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index f86ac7bc19..0498c4c526 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -409,9 +409,14 @@ def lastgenre_func(lib, opts, args): for album in lib.albums(ui.decargs(args)): album.genre, src = self._get_genre(album) self._log.info( - "genre for album {0} ({1}): {0.genre}", album, src + 'genre for album "{0.album}" ({1}): {0.genre}', + album, + src, ) - album.store() + if "track" in self.sources: + album.store(inherit=False) + else: + album.store() for item in album.items(): # If we're using track-level sources, also look up each @@ -420,7 +425,7 @@ def lastgenre_func(lib, opts, args): item.genre, src = self._get_genre(item) item.store() self._log.info( - "genre for track {0} ({1}): {0.genre}", + 'genre for track "{0.title}" ({1}): {0.genre}', item, src, ) @@ -432,10 +437,10 @@ def lastgenre_func(lib, opts, args): # an album for item in lib.items(ui.decargs(args)): item.genre, src = self._get_genre(item) - self._log.debug( - "added last.fm item genre ({0}): {1}", src, item.genre - ) item.store() + self._log.info( + "genre for track {0.title} ({1}): {0.genre}", item, src + ) lastgenre_cmd.func = lastgenre_func return [lastgenre_cmd] @@ -446,23 +451,32 @@ def imported(self, session, task): album = task.album album.genre, src = self._get_genre(album) self._log.debug( - "added last.fm album genre ({0}): {1}", src, album.genre + 'genre for album "{0.album}" ({1}): {0.genre}', album, src ) - album.store() + # If we're using track-level sources, store the album genre only, + # then also look up individual track genres. if "track" in self.sources: + album.store(inherit=False) for item in album.items(): item.genre, src = self._get_genre(item) self._log.debug( - "added last.fm item genre ({0}): {1}", src, item.genre + 'genre for track "{0.title}" ({1}): {0.genre}', + item, + src, ) item.store() + # Store the album genre and inherit to tracks. + else: + album.store() else: item = task.item item.genre, src = self._get_genre(item) self._log.debug( - "added last.fm item genre ({0}): {1}", src, item.genre + 'genre for track "{0.title}" ({1}): {0.genre}', + item, + src, ) item.store() diff --git a/docs/changelog.rst b/docs/changelog.rst index d318b053a3..186749d461 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -33,6 +33,11 @@ Bug fixes: * :ref:`query-sort`: Fix a bug that would raise an exception when sorting on a non-string field that is not populated in all items. :bug:`5512` +* :doc:`plugins/lastgenre`: Fix track-level genre handling. Now when an album-level + genre is set already, single tracks don't fall back to the album's genre and + request their own last.fm genre. Also log messages regarding what's been + tagged are now more polished. + :bug:`5582` For packagers: