mirror of
https://github.com/beetbox/beets.git
synced 2026-02-08 16:34:12 +01:00
fix(lastgenre): Canonicalize keep_existing fallback (#6303)
This commit is contained in:
commit
a327c28470
3 changed files with 35 additions and 0 deletions
|
|
@ -482,6 +482,13 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
if obj.genre and self.config["keep_existing"]:
|
||||
if not self.whitelist or self._is_valid(obj.genre.lower()):
|
||||
return obj.genre, "original fallback"
|
||||
else:
|
||||
# If the original genre doesn't match a whitelisted genre, check
|
||||
# if we can canonicalize it to find a matching, whitelisted genre!
|
||||
if result := _try_resolve_stage(
|
||||
"original fallback", keep_genres, []
|
||||
):
|
||||
return result
|
||||
|
||||
# Return fallback string.
|
||||
if fallback := self.config["fallback"].get():
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ New features:
|
|||
|
||||
Bug fixes:
|
||||
|
||||
- :doc:`/plugins/lastgenre`: Canonicalize genres when ``force`` and
|
||||
``keep_existing`` are ``on``, yet no genre info on lastfm could be found.
|
||||
:bug:`6303`
|
||||
- Handle potential OSError when unlinking temporary files in ArtResizer.
|
||||
:bug:`5615`
|
||||
- :doc:`/plugins/spotify`: Updated Spotify API credentials. :bug:`6270`
|
||||
|
|
|
|||
|
|
@ -541,6 +541,31 @@ class LastGenrePluginTest(PluginTestCase):
|
|||
"keep + album, whitelist",
|
||||
),
|
||||
),
|
||||
# 16 - canonicalization transforms non-whitelisted original genres to canonical
|
||||
# forms and deduplication works, **even** when no new genres are found online.
|
||||
#
|
||||
# "Cosmic Disco" is not in the default whitelist, thus gets resolved "up" in the
|
||||
# tree to "Disco" and "Electronic".
|
||||
(
|
||||
{
|
||||
"force": True,
|
||||
"keep_existing": True,
|
||||
"source": "album",
|
||||
"whitelist": True,
|
||||
"canonical": True,
|
||||
"prefer_specific": False,
|
||||
"count": 10,
|
||||
},
|
||||
"Cosmic Disco",
|
||||
{
|
||||
"album": [],
|
||||
"artist": [],
|
||||
},
|
||||
(
|
||||
"Disco, Electronic",
|
||||
"keep + original fallback, whitelist",
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_get_genre(config_values, item_genre, mock_genres, expected_result):
|
||||
|
|
|
|||
Loading…
Reference in a new issue