[GH-ISSUE #229] Error while I extract the songs from every public playlist of a user #118

Closed
opened 2026-02-27 23:20:55 +03:00 by kerem · 1 comment
Owner

Originally created by @luismiguells on GitHub (Nov 7, 2017).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/229

Hi everyone I try to extract every song on a public playlist of a user at the begin everything goes ok but at some point throws me a error here is my code:

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

#Show tracks
def show_tracks(results):
    for i, item in enumerate(results['items']):
        track = item['track']
        if track != None:    
            print("%d %s: %s" % (i, track['artists'][0]['name'], track['name']))
        else:
            pass

#Auth
client_credentials_manager = SpotifyClientCredentials(
        client_id = '*****', 
        client_secret = '*****')  

spotify = spotipy.Spotify(client_credentials_manager = client_credentials_manager)

#user = 'lucy.cgtz'
user = '1296791898'
playlists = spotify.user_playlists(user)


#Show the list and next show the tracks
while playlists:
    for i, playlist in enumerate(playlists['items']):
        print("%4d %s %s" % (i + 1 + playlists['offset'], playlist['uri'],  playlist['name']))
        results = spotify.user_playlist(user, playlist['id'], fields="tracks, next")
        tracks = results['tracks']
        show_tracks(tracks)
        while tracks['next']:
            tracks = spotify.next(tracks)
            show_tracks(tracks)
    #if playlists['next']:
    #       playlists = spotify.next(playlists)
    #else:
    #    playlists = None

Throws me this error:


SpotifyException: https://api.spotify.com/v1/users/1296791898/playlists/1kAgnWp6dNhJukgUOJuLCo?fields=tracks%2C+next:
 Not found.

The problem here is that playlist really exist any suggestions for this, thank you

Originally created by @luismiguells on GitHub (Nov 7, 2017). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/229 Hi everyone I try to extract every song on a public playlist of a user at the begin everything goes ok but at some point throws me a error here is my code: ``` import spotipy from spotipy.oauth2 import SpotifyClientCredentials #Show tracks def show_tracks(results): for i, item in enumerate(results['items']): track = item['track'] if track != None: print("%d %s: %s" % (i, track['artists'][0]['name'], track['name'])) else: pass #Auth client_credentials_manager = SpotifyClientCredentials( client_id = '*****', client_secret = '*****') spotify = spotipy.Spotify(client_credentials_manager = client_credentials_manager) #user = 'lucy.cgtz' user = '1296791898' playlists = spotify.user_playlists(user) #Show the list and next show the tracks while playlists: for i, playlist in enumerate(playlists['items']): print("%4d %s %s" % (i + 1 + playlists['offset'], playlist['uri'], playlist['name'])) results = spotify.user_playlist(user, playlist['id'], fields="tracks, next") tracks = results['tracks'] show_tracks(tracks) while tracks['next']: tracks = spotify.next(tracks) show_tracks(tracks) #if playlists['next']: # playlists = spotify.next(playlists) #else: # playlists = None ``` Throws me this error: ``` SpotifyException: https://api.spotify.com/v1/users/1296791898/playlists/1kAgnWp6dNhJukgUOJuLCo?fields=tracks%2C+next: Not found. ``` The problem here is that playlist really exist any suggestions for this, thank you
kerem closed this issue 2026-02-27 23:20:55 +03:00
Author
Owner

@ritiek commented on GitHub (Nov 7, 2017):

It seems like the playlists of the user you're trying to fetch follows some playlists from other users. So, the original owner of the playlist in that case is not the user you specified but is the one who actually created the playlist.

Replacing user with playlist['owner']['id'] in

results = spotify.user_playlist(user, playlist['id'], fields="tracks, next")

should fix this.

<!-- gh-comment-id:342556642 --> @ritiek commented on GitHub (Nov 7, 2017): It seems like the playlists of the user you're trying to fetch follows some playlists from other users. So, the original owner of the playlist in that case is not the user you specified but is the one who actually created the playlist. Replacing `user` with `playlist['owner']['id']` in ``` results = spotify.user_playlist(user, playlist['id'], fields="tracks, next") ``` should fix this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#118
No description provided.