diff --git a/docs/index.rst b/docs/index.rst index f652dd2..0f3ba87 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -271,7 +271,7 @@ Shows the contents of every playlist owned by a user:: print() print(playlist['name']) print (' total tracks', playlist['tracks']['total']) - results = sp.user_playlist(username, playlist['id'], + results = sp.playlist(playlist['id'], fields="tracks,next") tracks = results['tracks'] show_tracks(tracks) diff --git a/examples/read_a_playlist.py b/examples/read_a_playlist.py index e38676f..06cad00 100644 --- a/examples/read_a_playlist.py +++ b/examples/read_a_playlist.py @@ -5,9 +5,6 @@ import json client_credentials_manager = SpotifyClientCredentials() sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager) -uri = 'spotify:user:spotifycharts:playlist:37i9dQZEVXbJiZcmkrIHGU' -username = uri.split(':')[2] -playlist_id = uri.split(':')[4] - -results = sp.user_playlist(username, playlist_id) +playlist_id = 'spotify:user:spotifycharts:playlist:37i9dQZEVXbJiZcmkrIHGU' +results = sp.playlist(playlist_id) print(json.dumps(results, indent=4)) diff --git a/examples/user_playlists_contents.py b/examples/user_playlists_contents.py index b6cb7d2..a36006a 100644 --- a/examples/user_playlists_contents.py +++ b/examples/user_playlists_contents.py @@ -31,8 +31,7 @@ if __name__ == '__main__': print() print(playlist['name']) print(' total tracks', playlist['tracks']['total']) - results = sp.user_playlist( - username, playlist['id'], fields="tracks,next") + results = sp.playlist(playlist['id'], fields="tracks,next") tracks = results['tracks'] show_tracks(tracks) while tracks['next']: diff --git a/examples/user_starred_playlist.py b/examples/user_starred_playlist.py deleted file mode 100644 index 4d51456..0000000 --- a/examples/user_starred_playlist.py +++ /dev/null @@ -1,30 +0,0 @@ -# shows a user's starred playlist - -import sys -import spotipy -import spotipy.util as util - - -if len(sys.argv) > 1: - username = sys.argv[1] -else: - print("Whoops, need your username!") - print("usage: python user_playlists.py [username]") - sys.exit() - -token = util.prompt_for_user_token(username) - -if token: - sp = spotipy.Spotify(auth=token) - results = sp.user_playlist(username) - tracks = results['tracks'] - which = 1 - while tracks: - for item in tracks['items']: - track = item['track'] - print(which, track['name'], ' --', track['artists'][0]['name']) - which += 1 - tracks = sp.next(tracks) - -else: - print("Can't get token for", username)