spotipy: 'Search' funtion does not retrieve all playlists
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
playlists = []
for offset in range(0, 1000, 50):
playlists = playlists + spotify.search(q="Folk punk", limit=50, offset=offset, type='playlist').get('playlists')['items']
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 punk/playlists) - here is the output that I expect to see.
Environment:
- OS: Windows
- Python version 3.7.0
- spotipy version 2.19.0
- Google Colab
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:
spotify_playlists = []
for offset in range(0, 2000, 10):
spotify_playlists = spotify_playlists + spotify.user_playlists(user = 'spotify', limit=10, offset=offset)['items']
print(len(spotify_playlists))
I am getting less number of playlists (1177) Is there something that I missed?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 28 (13 by maintainers)
Okay. @stephanebruckert Thank you very very much for your help. The solution for this Issue is to use SpotifyOAuth instead of SpotifyClientCredentials.
It’s the same AFAIK
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?
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!@stephanebruckert At least, I am not alone with this issue, I appreciate your help)