mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-04 23:17:48 +00:00
added current_user_playlists example
This commit is contained in:
parent
76df337079
commit
18e5811539
26
examples/my_playlists.py
Normal file
26
examples/my_playlists.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Shows the top artists for a user
|
||||
|
||||
import pprint
|
||||
import sys
|
||||
|
||||
import spotipy
|
||||
import spotipy.util as util
|
||||
import simplejson as json
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
username = sys.argv[1]
|
||||
else:
|
||||
print("Usage: %s username" % (sys.argv[0],))
|
||||
sys.exit()
|
||||
|
||||
scope = ''
|
||||
token = util.prompt_for_user_token(username, scope)
|
||||
|
||||
if token:
|
||||
sp = spotipy.Spotify(auth=token)
|
||||
sp.trace = False
|
||||
results = sp.current_user_playlists(limit=50)
|
||||
for i, item in enumerate(results['items']):
|
||||
print("%d %s" %(i, item['name']))
|
||||
else:
|
||||
print("Can't get token for", username)
|
Loading…
Reference in New Issue
Block a user