spotify.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Chorus 作者: DonaldBough 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号