mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #768] Can't search for artist and year at the same time #467
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#467
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Zacharias3D on GitHub (Jan 10, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/768
Hi everyone,
I am trying to use the
search-function to query for a specific song from a specific year.To accomplish this I call the
search-function withq=track:Chattanooga Choo Choo+year:1939. This works just fine when trying the request in postman, but when executing it in Python I do not get any results.When I debugged, I realized that in the
_encode_params()-function of the models-module in requests-lib, my query string is encoded which leads to the replacement of the joining "+" in my query-string ("+" becomes "%2B"). It seems though, that the Spotify API needs a "+" and not a URI-encoded "+".When trying the query-string
track:Chattanooga%20Choo%20Choo%2Byear:1939in postman I also got no results. Replacing "%2B" with "+" showed me results again.Any advice? I probably just oversee some simple issue.
Greetings,
Zacharias
@Peter-Schorn commented on GitHub (Jan 11, 2022):
A literal
+character must be percent-encoded to%2B, otherwise is the percent-encoded form of the space character. (A space character can also be percent-encoded as%20).When you make the request in Postman, it assumes that the
+is already the percent-encoded form of the space character. Therefore, the percent-decoded form of theqquery parameter value in the Postman request istrack:Chattanooga Choo Choo year:1939. Notice there is no+character. This is what you're searching for in Postman.spotipy, on the other hand, will percent-encode the query, even if it is already percent-encoded. Therefore, it will percent-encode the
+character to%2B. Therefore, the percent-decoded form of theqquery parameter value in the spotipy request istrack:Chattanooga Choo Choo+year:1939, which is exactly (and always will be) what you passed in to thesearchmethod originally. Do not percent-encode the query yourself beforehand. There is no track namedChattanooga Choo Choo+(with a+character), so you get no results.@Zacharias3D commented on GitHub (Jan 11, 2022):
Oh my god..
Thanks so much. Who would have thought that a "+" too much would cost me hours of my day.
Thanks a lot!!!