mirror of
https://github.com/beetbox/beets.git
synced 2025-12-29 20:12:33 +01:00
Fix for Spotify Candidate Lookup. Changed query from double to single quotes. (#6049)
I noticed that spotify did not return any candidates for some of my examples, but adding the search id manually would give a very good match. I debugged it a bit and it seems like spotify does not like double quotes we used for the search query. Using single quotes fixed it for me. Note that this does not seem to be documented in the [spotify api documentation](https://developer.spotify.com/documentation/web-api/reference/search) The example I used: ``` # Query with double quotes, which does not return any candidates # Searching Spotify for 'album:"Flamethrower" artist:"Circadian, Cody Frost"' https://api.spotify.com/v1/search?offset=0&limit=50&query=album%3A%22Flamethrower%22%20artist%3A%22Circadian%2C%20Cody%20Frost%22&type=album # New Query # Searching Spotify for 'album:'Flamethrower' artist:'Circadian, Cody Frost'' https://api.spotify.com/v1/search?offset=0&limit=5&query=album%3A%27Flamethrower%27%20artist%3A%27Circadian%2C%20Cody%20Frost%27&type=album ```
This commit is contained in:
commit
bc9d34ed98
3 changed files with 9 additions and 7 deletions
|
|
@ -412,7 +412,7 @@ class SearchApiMetadataSourcePlugin(
|
|||
:return: Query string to be provided to the search API.
|
||||
"""
|
||||
|
||||
components = [query_string, *(f'{k}:"{v}"' for k, v in filters.items())]
|
||||
components = [query_string, *(f"{k}:'{v}'" for k, v in filters.items())]
|
||||
query = " ".join(filter(None, components))
|
||||
|
||||
if self.config["search_query_ascii"].get():
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ Bug fixes:
|
|||
matching. :bug:`5189`
|
||||
- :doc:`plugins/discogs` Fixed inconsistency in stripping disambiguation from
|
||||
artists but not labels. :bug:`5366`
|
||||
- :doc:`plugins/spotify` Fixed an issue where candidate lookup would not find
|
||||
matches due to query escaping (single vs double quotes).
|
||||
|
||||
For packagers:
|
||||
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ class SpotifyPluginTest(PluginTestCase):
|
|||
params = _params(responses.calls[0].request.url)
|
||||
query = params["q"][0]
|
||||
assert "duifhjslkef" in query
|
||||
assert 'artist:"ujydfsuihse"' in query
|
||||
assert 'album:"lkajsdflakjsd"' in query
|
||||
assert "artist:'ujydfsuihse'" in query
|
||||
assert "album:'lkajsdflakjsd'" in query
|
||||
assert params["type"] == ["track"]
|
||||
|
||||
@responses.activate
|
||||
|
|
@ -117,8 +117,8 @@ class SpotifyPluginTest(PluginTestCase):
|
|||
params = _params(responses.calls[0].request.url)
|
||||
query = params["q"][0]
|
||||
assert "Happy" in query
|
||||
assert 'artist:"Pharrell Williams"' in query
|
||||
assert 'album:"Despicable Me 2"' in query
|
||||
assert "artist:'Pharrell Williams'" in query
|
||||
assert "album:'Despicable Me 2'" in query
|
||||
assert params["type"] == ["track"]
|
||||
|
||||
@responses.activate
|
||||
|
|
@ -233,8 +233,8 @@ class SpotifyPluginTest(PluginTestCase):
|
|||
params = _params(responses.calls[0].request.url)
|
||||
query = params["q"][0]
|
||||
assert item.title in query
|
||||
assert f'artist:"{item.albumartist}"' in query
|
||||
assert f'album:"{item.album}"' in query
|
||||
assert f"artist:'{item.albumartist}'" in query
|
||||
assert f"album:'{item.album}'" in query
|
||||
assert not query.isascii()
|
||||
|
||||
# Is not found in the library if ascii encoding is enabled
|
||||
|
|
|
|||
Loading…
Reference in a new issue