mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
Update/remove outdated examples
This commit is contained in:
parent
7fb97ed00e
commit
45c3e5e951
@ -271,7 +271,7 @@ Shows the contents of every playlist owned by a user::
|
|||||||
print()
|
print()
|
||||||
print(playlist['name'])
|
print(playlist['name'])
|
||||||
print (' total tracks', playlist['tracks']['total'])
|
print (' total tracks', playlist['tracks']['total'])
|
||||||
results = sp.user_playlist(username, playlist['id'],
|
results = sp.playlist(playlist['id'],
|
||||||
fields="tracks,next")
|
fields="tracks,next")
|
||||||
tracks = results['tracks']
|
tracks = results['tracks']
|
||||||
show_tracks(tracks)
|
show_tracks(tracks)
|
||||||
|
|||||||
@ -5,9 +5,6 @@ import json
|
|||||||
client_credentials_manager = SpotifyClientCredentials()
|
client_credentials_manager = SpotifyClientCredentials()
|
||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
|
|
||||||
uri = 'spotify:user:spotifycharts:playlist:37i9dQZEVXbJiZcmkrIHGU'
|
playlist_id = 'spotify:user:spotifycharts:playlist:37i9dQZEVXbJiZcmkrIHGU'
|
||||||
username = uri.split(':')[2]
|
results = sp.playlist(playlist_id)
|
||||||
playlist_id = uri.split(':')[4]
|
|
||||||
|
|
||||||
results = sp.user_playlist(username, playlist_id)
|
|
||||||
print(json.dumps(results, indent=4))
|
print(json.dumps(results, indent=4))
|
||||||
|
|||||||
@ -31,8 +31,7 @@ if __name__ == '__main__':
|
|||||||
print()
|
print()
|
||||||
print(playlist['name'])
|
print(playlist['name'])
|
||||||
print(' total tracks', playlist['tracks']['total'])
|
print(' total tracks', playlist['tracks']['total'])
|
||||||
results = sp.user_playlist(
|
results = sp.playlist(playlist['id'], fields="tracks,next")
|
||||||
username, playlist['id'], fields="tracks,next")
|
|
||||||
tracks = results['tracks']
|
tracks = results['tracks']
|
||||||
show_tracks(tracks)
|
show_tracks(tracks)
|
||||||
while tracks['next']:
|
while tracks['next']:
|
||||||
|
|||||||
@ -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)
|
|
||||||
Loading…
Reference in New Issue
Block a user