From 18e5811539b4ea35667934e5c9d9476419abf98b Mon Sep 17 00:00:00 2001 From: Paul Lamere Date: Sat, 31 Dec 2016 10:19:43 -0500 Subject: [PATCH] added current_user_playlists example --- examples/my_playlists.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/my_playlists.py diff --git a/examples/my_playlists.py b/examples/my_playlists.py new file mode 100644 index 0000000..58e02df --- /dev/null +++ b/examples/my_playlists.py @@ -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)