From 9cbbad19f80dc69fd4626be3052ebd0233b9a40a Mon Sep 17 00:00:00 2001 From: Arden Rasmussen Date: Wed, 17 Dec 2025 15:57:23 -0800 Subject: [PATCH] remove changes for lastgenre as there was an existing PR for that work --- beetsplug/lastgenre/__init__.py | 63 +++------------------------------ docs/changelog.rst | 3 -- test/plugins/test_lastgenre.py | 50 +++++--------------------- 3 files changed, 13 insertions(+), 103 deletions(-) diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index 3873f5f93..ea0ab951a 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -302,76 +302,23 @@ class LastGenrePlugin(plugins.BeetsPlugin): def fetch_album_genre(self, obj): """Return raw album genres from Last.fm for this Item or Album.""" - genre = self._last_lookup( + return self._last_lookup( "album", LASTFM.get_album, obj.albumartist, obj.album ) - if genre: - return genre - - # If no genres found for the joint 'albumartist', try the individual - # album artists if available in 'albumartists'. - if obj.albumartists and len(obj.albumartists) > 1: - for albumartist in obj.albumartists: - genre = self._last_lookup( - "album", LASTFM.get_album, albumartist, obj.album - ) - - if genre: - return genre - - return genre def fetch_album_artist_genre(self, obj): """Return raw album artist genres from Last.fm for this Item or Album.""" - genres = self._last_lookup("artist", LASTFM.get_artist, obj.albumartist) - if genres: - return genres + return self._last_lookup("artist", LASTFM.get_artist, obj.albumartist) - # If no genres found for the joint 'albumartist', try the individual - # album artists if available in 'albumartists'. - if obj.albumartists and len(obj.albumartists) > 1: - for albumartist in obj.albumartists: - genre = self._last_lookup( - "artist", LASTFM.get_artist, albumartist - ) - - if genre: - return genre - return genres - - def fetch_artist_genre(self, obj): + def fetch_artist_genre(self, item): """Returns raw track artist genres from Last.fm for this Item.""" - genres = self._last_lookup("artist", LASTFM.get_artist, obj.artist) - if genres: - return genres - - # If no genres found for the joint 'artist', try the individual - # album artists if available in 'artists'. - if obj.artists and len(obj.artists) > 1: - for artist in obj.artists: - genre = self._last_lookup("artist", LASTFM.get_artist, artist) - if genre: - return genre - return genres + return self._last_lookup("artist", LASTFM.get_artist, item.artist) def fetch_track_genre(self, obj): """Returns raw track genres from Last.fm for this Item.""" - genres = self._last_lookup( + return self._last_lookup( "track", LASTFM.get_track, obj.artist, obj.title ) - if genres: - return genres - - # If no genres found for the joint 'artist', try the individual - # album artists if available in 'artists'. - if obj.artists and len(obj.artists) > 1: - for artist in obj.artists: - genre = self._last_lookup( - "track", LASTFM.get_track, artist, obj.title - ) - if genre: - return genre - return genres # Main processing: _get_genre() and helpers. diff --git a/docs/changelog.rst b/docs/changelog.rst index f1de4220d..6d37a64a4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -33,9 +33,6 @@ New features: resolve differences in metadata source styles. - :doc:`plugins/spotify`: Added support for multi-artist albums and tracks, saving all contributing artists to the respective fields. -- :doc:`plugins/lastgenre`: If looking up a multi-artist album or track, - fall back to searching the individual artists for genres when no results - are found for the combined artist string. Bug fixes: diff --git a/test/plugins/test_lastgenre.py b/test/plugins/test_lastgenre.py index c47a54e03..12ff30f8e 100644 --- a/test/plugins/test_lastgenre.py +++ b/test/plugins/test_lastgenre.py @@ -546,25 +546,24 @@ class LastGenrePluginTest(PluginTestCase): def test_get_genre(config_values, item_genre, mock_genres, expected_result): """Test _get_genre with various configurations.""" - def mock_fetch_track_genre(obj=None): + def mock_fetch_track_genre(self, obj=None): return mock_genres["track"] - def mock_fetch_album_genre(obj): + def mock_fetch_album_genre(self, obj): return mock_genres["album"] - def mock_fetch_artist_genre(obj): + def mock_fetch_artist_genre(self, obj): return mock_genres["artist"] - # Initialize plugin instance and item - plugin = lastgenre.LastGenrePlugin() - # Mock the last.fm fetchers. When whitelist enabled, we can assume only # whitelisted genres get returned, the plugin's _resolve_genre method # ensures it. - plugin.fetch_track_genre = mock_fetch_track_genre - plugin.fetch_album_genre = mock_fetch_album_genre - plugin.fetch_artist_genre = mock_fetch_artist_genre + lastgenre.LastGenrePlugin.fetch_track_genre = mock_fetch_track_genre + lastgenre.LastGenrePlugin.fetch_album_genre = mock_fetch_album_genre + lastgenre.LastGenrePlugin.fetch_artist_genre = mock_fetch_artist_genre + # Initialize plugin instance and item + plugin = lastgenre.LastGenrePlugin() # Configure plugin.config.set(config_values) plugin.setup() # Loads default whitelist and canonicalization tree @@ -574,36 +573,3 @@ def test_get_genre(config_values, item_genre, mock_genres, expected_result): # Run res = plugin._get_genre(item) assert res == expected_result - - -def test_multiartist_fallback(): - def mock_lookup(entity, method, *args): - # Only response for the first artist, e.g. no results for the joint - # artist - if entity == "album" and args[0] == "Project Skylate": - return ["Electronic"] - return [] - - plugin = lastgenre.LastGenrePlugin() - plugin._last_lookup = mock_lookup - plugin.config.set( - { - "force": True, - "keep_existing": False, - "source": "album", - "whitelist": True, - "canonical": False, - "count": 5, - } - ) - plugin.setup() - - res = plugin._get_genre( - _common.item( - albumartist="Project Skylate & Sugar Shrill", - albumartists=["Project Skylate", "Sugar Shrill"], - artist="Project Skylate & Sugar Shrill", - artists=["Project Skylate", "Sugar Shrill"], - ) - ) - assert res == ("Electronic", "album, whitelist")