remove changes for lastgenre as there was an existing PR for that work

This commit is contained in:
Arden Rasmussen 2025-12-17 15:57:23 -08:00
parent 01e0aeb662
commit 9cbbad19f8
3 changed files with 13 additions and 103 deletions

View file

@ -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.

View file

@ -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:

View file

@ -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")