2014-05-16 15:32:55 +00:00
|
|
|
# shows a user's playlists (need to be authenticated via oauth)
|
|
|
|
|
|
|
|
import pprint
|
|
|
|
import sys
|
2014-05-18 11:08:51 +00:00
|
|
|
import os
|
2014-05-19 11:24:09 +00:00
|
|
|
import subprocess
|
2014-05-16 15:32:55 +00:00
|
|
|
|
|
|
|
import spotipy
|
2014-05-23 11:19:16 +00:00
|
|
|
|
2014-05-18 11:08:51 +00:00
|
|
|
import spotipy.oauth2 as oauth2
|
2014-08-14 10:39:24 +00:00
|
|
|
import spotipy.util as util
|
2014-05-23 11:19:16 +00:00
|
|
|
|
|
|
|
|
2014-05-16 15:32:55 +00:00
|
|
|
if len(sys.argv) > 1:
|
|
|
|
username = sys.argv[1]
|
|
|
|
else:
|
2014-05-18 11:08:51 +00:00
|
|
|
print "Whoops, need your username!"
|
|
|
|
print "usage: python user_playlists.py [username]"
|
2014-05-16 15:32:55 +00:00
|
|
|
sys.exit()
|
|
|
|
|
2014-05-23 11:19:16 +00:00
|
|
|
token = util.prompt_for_user_token(username)
|
2014-05-19 11:24:09 +00:00
|
|
|
|
2014-05-23 11:19:16 +00:00
|
|
|
if token:
|
|
|
|
sp = spotipy.Spotify(auth=token)
|
|
|
|
playlists = sp.user_playlists(username)
|
|
|
|
for playlist in playlists['items']:
|
|
|
|
print playlist['name']
|
|
|
|
else:
|
|
|
|
print "Can't get token for", username
|