mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #522] Search doesn't find some tracks #315
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#315
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 @alpha23 on GitHub (Jun 29, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/522
I am searching for some tracks by a query which contains the artist and the track name. On some queries I don't get any results. When I use the same query via the Spotify console I will get the information i am searching for.
Here is the code I used to search the track with spotipy:
query = "Room Eleven Baby it's cold outside"sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())results = sp.search(q=query, type="track", limit=20, offset=0)print(results)If I am using my own code to request the data from the Spotify API I get the same result like I get in the Spotify console:
query = "Room Eleven Baby it's cold outside"token = "XYZ"headers = {"Authorization": "Bearer {0}".format(token)}response = requests.get("https://api.spotify.com/v1/search?q={0}&type=track".format(query), headers=headers)data = response.json()print(data)Even if I use sp._get() with exactly the same URI like in the plain requests.get() call I cannot get any results:
data = sp._get("https://api.spotify.com/v1/search?q={0}&type=track".format(query))print(data)Is there something that is limited when I use SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET or is this just a bug?
Best regards
Mark Herzberg
@GaryOma commented on GitHub (Jun 30, 2020):
I used to get the same problem few days ago. My fix was to change the market where you are making the search. By default I think it's using the "US" market, and for my searches I had to revert back to a "FR" market to get some results.
Insert the market here with the
marketparameter :results = sp.search(q=query, type="track", limit=20, offset=0, market="YOUR MARKET").You can get the list of the syntax for the markets here : ISO 3166-1 alpha-2.
@stephanebruckert commented on GitHub (Jun 30, 2020):
Let's add @GaryOma's answer to the FAQ
@alpha23 commented on GitHub (Jun 30, 2020):
@GaryOma It seems like this really did the trick. Thank you for your advise!