def createPlaylist(self, token):
#db = Database()
#token = db.getEventSpotifyToken(eventID)
#use GET command to get user info
req = requests.get("https://api.spotify.com/v1/me", headers={"Authorization":'Bearer ' + token})
j = json.loads(req.text)
userID = j['id']
#print("userID === " + userID)
playlist_name = 'Chorus'
sp = spotipy.Spotify(auth=token)
sp.trace = False
sp.user_playlist_create(userID, playlist_name)
playlists = sp.user_playlists(userID, limit=50, offset=0)
for playlist in playlists['items']:
if(playlist['name'] == "Chorus"):
playlist_id = playlist['id']
headers={"Authorization":'Bearer ' + token}
requests.put('https://api.spotify.com/v1/me/player/shuffle?state=false',headers={"Authorization":'Bearer ' + token})
data = []
data.append(userID)
data.append(playlist_id)
return data
评论列表
文章目录