调用Spotipy的recommendation_genre_seeds()函数获取Spotify流派时遭遇404错误求助
调用Spotipy的recommendation_genre_seeds()函数获取Spotify流派时遭遇404错误求助
我目前正在开发一个应用,它接收用户的提示和他们的收听数据,然后为用户创建播放列表。我还会用BART模型分析用户提示,找出最适合的音乐流派。
大概3-4周前我编写这部分代码时一切运行正常,但最近一周,当我尝试用Spotipy库的recommendation_genre_seeds()函数获取Spotify支持的流派列表时,突然遇到了之前没有的异常。
我在Jupyter Notebook里做了调试,已经初始化好了Spotipy客户端:
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, redirect_uri=REDIRECT_URI, scope="playlist-modify-private playlist-modify-public user-top-read user-read-recently-played user-library-read user-follow-read"))
抛出异常的代码片段是:sp.recommendation_genre_seeds()
得到的异常如下:
HTTP Error for GET to https://api.spotify.com/v1/recommendations/available-genre-seeds with Params: {} returned 404 due to None --------------------------------------------------------------------------- HTTPError Traceback (most recent call last) ~\anaconda3\lib\site-packages\spotipy\client.py in _internal_call(self, method, url, payload, params) 274 ---> 275 response.raise_for_status() 276 results = response.json() ~\anaconda3\lib\site-packages\requests\models.py in raise_for_status(self) 1020 if http_error_msg: -> 1021 raise HTTPError(http_error_msg, response=self) 1022 HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/recommendations/available-genre-seeds During handling of the above exception, another exception occurred: SpotifyException Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_19528\936109238.py in <module> ----> 1 sp.recommendation_genre_seeds() ~\anaconda3\lib\site-packages\spotipy\client.py in recommendation_genre_seeds(self) 1731 """ Get a list of genres available for the recommendations function. 1732 """ -> 1733 return self._get("recommendations/available-genre-seeds") 1734 1735 def audio_analysis(self, track_id): ~\anaconda3\lib\site-packages\spotipy\client.py in _get(self, url, args, payload, **kwargs) 325 kwargs.update(args) 326 -> 327 return self._internal_call("GET", url, payload, kwargs) 328 329 def _post(self, url, args=None, payload=None, **kwargs): ~\anaconda3\lib\site-packages\spotipy\client.py in _internal_call(self, method, url, payload, params) 295 ) 296 -> 297 raise SpotifyException( 298 response.status_code, 299 -1, SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/recommendations/available-genre-seeds: None, reason: None
请问是不是Spotify API出了问题导致Spotipy出现这样的崩溃?我已经查过一些资料,隐约觉得是这个原因,但想确认一下,同时也想知道有没有解决这个错误的办法。
另外,如果我的提问有什么问题也请告诉我,这是我第一次在StackOverflow发帖,谢谢!
备注:内容来源于stack exchange,提问作者spinelessknave8
相关产品推荐
相关产品推荐

