我使用Spotipy和LyricsGenius从终端在web浏览器上打开歌词
我可以打开一首歌的url,但每次都必须运行脚本才能连续运行。使用Spotipy检测歌曲结尾的方法有哪些
import spotipy
import webbrowser
import lyricsgenius as lg
...
# Create our spotifyObject
spotifyObject = spotipy.Spotify(auth=token)
# Create out geniusObject
geniusObject = lg.Genius(access_token)
...
while True:
currently_playing = spotifyObject.currently_playing()
artist = currently_playing['item']['artists'][0]['name']
title = currently_playing['item']['name']
search_query = artist + " " + title
# if (currently_playing has changed):
song = geniusObject.search_songs(search_query)
song_url = song['hits'][0]['result']['url']
webbrowser.open(song_url)
webbrowser.open(song_url)
我正在阅读相关的线程,如this、this,并通读了文档,但如果Spotipy能够处理这个问题,我找不到答案。如果您有任何建议,我将不胜感激,谢谢
我使用time.sleep(length),参数“length”代表当前曲目的剩余持续时间
相关问题 更多 >
编程相关推荐