def recommend_fallback(self, eventID):
db = Database()
token = db.getEventSpotifyToken(eventID)
playlist_id = db.getPlaylistID(eventID)
username = db.getHostID(eventID)
track_id = db.getCurrentPlayingSong(eventID)
headers={"Authorization":'Bearer ' + token}
count = 0
sp = spotipy.Spotify(auth=token)
sp.trace = False
req = requests.get('https://api.spotify.com/v1/recommendations?seed_tracks=' + track_id, headers={"Authorization":"Bearer "+str(token)})
#print(req.content)
json_obj = json.loads(req.text)
for i in json_obj['tracks']:
if(count < 1):
return i
#addSongs(token, i, playlist_id, username)
count = count + 1
break
评论列表
文章目录