mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 17:16:07 +01:00
fix incorrect matches when album is missing or empty in spotify plugin search filter (#6012)
Only include non-empty artist and album filters in Spotify track search and metadata candidate queries to prevent incorrect matches when the album field is missing or empty. closes #5189
This commit is contained in:
commit
b65d773c8e
3 changed files with 20 additions and 9 deletions
|
|
@ -371,7 +371,9 @@ class SearchApiMetadataSourcePlugin(
|
||||||
album: str,
|
album: str,
|
||||||
va_likely: bool,
|
va_likely: bool,
|
||||||
) -> Iterable[AlbumInfo]:
|
) -> Iterable[AlbumInfo]:
|
||||||
query_filters: SearchFilter = {"album": album}
|
query_filters: SearchFilter = {}
|
||||||
|
if album:
|
||||||
|
query_filters["album"] = album
|
||||||
if not va_likely:
|
if not va_likely:
|
||||||
query_filters["artist"] = artist
|
query_filters["artist"] = artist
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,6 @@ class SpotifyPlugin(
|
||||||
"mode": "list",
|
"mode": "list",
|
||||||
"tiebreak": "popularity",
|
"tiebreak": "popularity",
|
||||||
"show_failures": False,
|
"show_failures": False,
|
||||||
"artist_field": "albumartist",
|
|
||||||
"album_field": "album",
|
|
||||||
"track_field": "title",
|
|
||||||
"region_filter": None,
|
"region_filter": None,
|
||||||
"regex": [],
|
"regex": [],
|
||||||
"client_id": "4e414367a1d14c75a5c5129a627fcab8",
|
"client_id": "4e414367a1d14c75a5c5129a627fcab8",
|
||||||
|
|
@ -563,13 +560,17 @@ class SpotifyPlugin(
|
||||||
regex["search"], regex["replace"], value
|
regex["search"], regex["replace"], value
|
||||||
)
|
)
|
||||||
|
|
||||||
# Custom values can be passed in the config (just in case)
|
artist = item["artist"] or item["albumartist"]
|
||||||
artist = item[self.config["artist_field"].get()]
|
album = item["album"]
|
||||||
album = item[self.config["album_field"].get()]
|
query_string = item["title"]
|
||||||
query_string = item[self.config["track_field"].get()]
|
|
||||||
|
|
||||||
# Query the Web API for each track, look for the items' JSON data
|
# Query the Web API for each track, look for the items' JSON data
|
||||||
query_filters: SearchFilter = {"artist": artist, "album": album}
|
query_filters: SearchFilter = {}
|
||||||
|
if artist:
|
||||||
|
query_filters["artist"] = artist
|
||||||
|
if album:
|
||||||
|
query_filters["album"] = album
|
||||||
|
|
||||||
response_data_tracks = self._search_api(
|
response_data_tracks = self._search_api(
|
||||||
query_type="track",
|
query_type="track",
|
||||||
query_string=query_string,
|
query_string=query_string,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,14 @@ New features:
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
|
- :doc:`plugins/spotify` Fixed an issue where track matching and lookups could
|
||||||
|
return incorrect or misleading results when using the Spotify plugin. The
|
||||||
|
problem occurred primarily when no album was provided or when the album field
|
||||||
|
was an empty string. :bug:`5189`
|
||||||
|
- :doc:`plugins/spotify` Removed old and undocumented config options
|
||||||
|
`artist_field`, `album_field` and `track` that were causing issues with track
|
||||||
|
matching. :bug:`5189`
|
||||||
|
|
||||||
For packagers:
|
For packagers:
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue