mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #850] 'Search' funtion does not retrieve all playlists #525
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#525
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 @KamranAbbaszadeIbrahim on GitHub (Sep 3, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/850
Describe the bug
When 'Search' function is used to query playlists matching certan key words, the results do not contain playlists, which are available on official web page of spotify. The search query is the same. While in results of Official Webpage of Spotify I can see playlists, created by Spotify (where owner of playlist is user with id=spotify), in results of Spotipy Library with the same search query, I sometimes get playlists created by Spotify user, sometimes I do not get any.
Your code
Expected behavior
I expect to retrieve from Spotipy the same results that I can get from Spotify Web Page.
Output
(https://open.spotify.com/search/Folk%20punk/playlists) - here is the output that I expect to see.
Environment:
Additional context
Additionally, I checked function from Spotipy - user_playlists.
While on https://open.spotify.com/user/spotify page I can see that Spotify user has 1520 public playlists, with almost the same code:
I am getting less number of playlists (1177) Is there something that I missed?
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
Is there any review for current issue?
@stephanebruckert commented on GitHub (Sep 7, 2022):
@KamranAbbaszadeIbrahim it works for me:
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
@stephanebruckert
If you will check the same search query in Browser on spotify web pge, you will see that there are Playlists by Spotify. But when you query it from google colab, it did not retrieve me any playlists by Spotify, only by independent users. In your example, it is Tom Sherman.
This bug is observed not in every query. In Some queries I can see Playlists created by Spotify, in others - No.
@stephanebruckert commented on GitHub (Sep 7, 2022):
Sorry I misread your initial post, however I can still see playlists from
spotify:user:spotifyin the results:@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
Could you explain, how did you get this result?
is it because you use SpotifyOAuth rather than SpotifyClientCredentials?
The only difference in my and your code is the Auth method.
I use client_id and client_secret that I generated.
And I did not get any result.
@stephanebruckert commented on GitHub (Sep 7, 2022):
Same with
SpotifyClientCredentials:@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
@stephanebruckert
I do really apologize, but I still do not understand why I can not get the same result as you?
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
@stephanebruckert
Additionally, I tried to register new account and create new client_id and client_secret.
It did not help.
@stephanebruckert commented on GitHub (Sep 7, 2022):
The only thing that comes to my mind is the current market being searched.
There can be differences between what you see between the web and api results https://github.com/plamere/spotipy/blob/master/FAQ.md#search-doesnt-find-some-tracks
According to https://developer.spotify.com/documentation/web-api/reference/#/operations/search it looks like Spotify is not searching the
usmarket code by default anymore.Therefore can you try to add
market='US'to the search method such as:or try to use different market codes from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 and see if it changes anything.
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
@stephanebruckert
I tried with
usmarket code - Did not work.I tried with next code
Again, no success. This is the output:
Click me
@stephanebruckert commented on GitHub (Sep 7, 2022):
Yeah not all markets are valid, that's fine.
Still your problem isn't solved. I run out of ideas and it might indeed be a bug on the Spotify API side. In any case it's not python related so I suggest you open a bug on https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer (feel free to post the link there for reference)
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
@stephanebruckert
I have one assumption, but in order to test it, I need your help.
Can you explain how to properly set the SpotifyOAuth especially redirect_url?
I want to check whether this issue occurs because of missing some scopes or not.
I can even share the client_id and client_secret of one of the accounts that I use, so that you can check whether it is issue with account or not.
@stephanebruckert commented on GitHub (Sep 7, 2022):
I'm happy to try with your client ID + secret if you send them to my email (can you see it on my profile?).
Your spotify app must have a redirect URI set (eg. http://localhost:8080), see https://spotipy.readthedocs.io/en/master/#redirect-uri. Then I use the code I pasted above and run it with:
You can also set the secrets like shown here https://github.com/plamere/spotipy#with-user-authentication
In the case of Google Colab it's a bit different, it's likely going to give you a URL that you must visit, and then you have to provide the result of that URL back to the terminal.
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
@stephanebruckert
I have sent you the client_id and client_secret via email.
I am trying to execute the code shared by you using redirect_url parameter. As soon as i get updates, I will share them.
@stephanebruckert commented on GitHub (Sep 7, 2022):
I tried one of your credentials, didn't work (no spotify playlist). Tried again with mine and didn't work either! I'm super confused. Give me some time, I'm trying to get my own credentials to work again
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
@stephanebruckert
At least, I am not alone with this issue, I appreciate your help)
@stephanebruckert commented on GitHub (Sep 7, 2022):
Ok I found the problem. After I switch from
SpotifyOAuthtoSpotifyClientCredentials, I didn't delete the cached token (.cache) on my local environment. So it was still usingSpotifyOAuth.Now I'm cleaning up the token after each run and I can confirm it works with
SpotifyOAuthand not withSpotifyClientCredentials!@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
@stephanebruckert
Okay, so I will describe my current issues with SpotifyOAuth.
I used:
In the Developer Dashboard, I went to Application Settings and set Redirect URIs the same value => http://localhost:4444/
I confirm that current port is free.
When I run the code in google colab, my code does not complete.
Any idea what I am doing wrong? It is already running 13 minutes.
I tried also to open google colab notebook in incognito , in Chrome.
@stephanebruckert commented on GitHub (Sep 7, 2022):
Check the last FAQ https://github.com/plamere/spotipy/blob/master/FAQ.md#how-do-i-obtain-authorization-in-a-headlessbrowserless-environment
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
@stephanebruckert
I could not apply successfully the steps described in the link((
@stephanebruckert commented on GitHub (Sep 7, 2022):
What is your code/error?
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
It always fails in Redirect_URI part.
I tried to generate token in Developer Console manually and it worked, I could run your code and retrieve results which I expected.
But, please, could you help me to be able to use next code?
@stephanebruckert commented on GitHub (Sep 7, 2022):
Don't use
util.prompt_for_user_tokenas it's deprecated, but use what's on the README https://github.com/plamere/spotipy#with-user-authentication withopen_browser=False.@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
I could make it work, but in this case, I had to go to specific url and then copy the redirected url into input box
And it worked. Is there any way, to not be in a need to do like this?
@stephanebruckert commented on GitHub (Sep 7, 2022):
This is the only way on Google Colab, because obviously your browser cannot open another browser/tab.
Locally you wouldn't have to do this but it would still open your browser and require you to sign in.
However, locally the token would be cached and refreshed automatically so you would only need to sign in once. On Google Colab I'm not sure you can cache the token.
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
How many request (approximatelly) I will be able to execute using this Auth method?
Because with SpotifyClientCredentials i was able to execute around 25K-27K requests per day. THen I was just changing manually the client_id and client_secret, cleaning cache and running again.
@stephanebruckert commented on GitHub (Sep 7, 2022):
It's the same AFAIK
@KamranAbbaszadeIbrahim commented on GitHub (Sep 7, 2022):
Okay.
@stephanebruckert Thank you very very much for your help.
The solution for this Issue is to use SpotifyOAuth instead of SpotifyClientCredentials.