我正在使用Spotipy和LyricsGenius从终端在网络浏览器上打开歌词。
我可以打开一首歌的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处理,我找不到答案。我将非常感谢您的建议,谢谢。
发布于 2020-11-07 05:22:36
我使用了长度(time.sleep),参数'length‘代表当前曲目的剩余持续时间。
https://stackoverflow.com/questions/64671057
复制相似问题