Spotipy访问轨道数据不再有效
我一直在使用Spotipy
和Spotify Web API
进行AI项目。我已经收到了预览_url的列表来进行一些分析,但我已经成功地遇到了很多,但是我最近遇到了问题。每当我尝试使用.track(track_id)
时,它就会卡在线上,并且不会继续越过线路。我当时认为这可能是API的问题,但是其他命令正常工作,这只是给我问题的曲目。我无法弄清楚这个问题,因为它没有给我任何错误,它只是被卡住了,试图执行该行而永远不会结束。 刷新客户秘密现在什么都没做。这是我到目前为止的代码。
from spotipy.oauth2 import SpotifyClientCredentials
cid = '121e03d3acd1440188ae4c0f58b844d4'
secret = '431a5e56bcd544c3aefce8166a9c3703'
client_credentials_manager = SpotifyClientCredentials(client_id=cid, client_secret=secret)
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
number = 2
output_file = open('data\\25k_data_preview\\track_url_preview_' + str(number) + '.txt', 'a')
for l in open('data\\25k_data\\track_url_' + str(number) + '.txt'):
line = l.replace('\n','')
print(line)
try:
track = sp.track(line)
try:
testing = track['preview_url']
if testing != None:
output_file.write(line + " " + testing + "\n")
except:
x = 0
except:
x = 0
output_file.close()
I have been working on an AI project using Spotipy
and the Spotify Web API
. I have been getting a list of preview_url's to do some analysis on and I have successfully gotten many, but I ran into issues lately. Whenever I try to use .track(track_id)
it gets stuck on the line and doesn't continue past the line. I was thinking it could be an issue with the API, but other commands work fine, it's only track that is giving me issues. I cannot figure out the issue because it doesn't give me any errors, it just gets stuck trying to execute that line and never finishes.
Refreshing the client secret does nothing now. This is the code I have so far.
from spotipy.oauth2 import SpotifyClientCredentials
cid = '121e03d3acd1440188ae4c0f58b844d4'
secret = '431a5e56bcd544c3aefce8166a9c3703'
client_credentials_manager = SpotifyClientCredentials(client_id=cid, client_secret=secret)
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
number = 2
output_file = open('data\\25k_data_preview\\track_url_preview_' + str(number) + '.txt', 'a')
for l in open('data\\25k_data\\track_url_' + str(number) + '.txt'):
line = l.replace('\n','')
print(line)
try:
track = sp.track(line)
try:
testing = track['preview_url']
if testing != None:
output_file.write(line + " " + testing + "\n")
except:
x = 0
except:
x = 0
output_file.close()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论