首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Spotipy检测歌曲的结尾

使用Spotipy检测歌曲的结尾
EN

Stack Overflow用户
提问于 2020-11-04 05:35:52
回答 1查看 128关注 0票数 0

我正在使用SpotipyLyricsGenius从终端在网络浏览器上打开歌词。

我可以打开一首歌的url,但每次都必须运行脚本才能连续运行。使用Spotipy检测一首歌的结尾有哪些方法?

代码语言:javascript
复制
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)

我正在阅读相关的线程,如thisthis,并通读了文档,但我的问题是否可以由Spotipy处理,我找不到答案。我将非常感谢您的建议,谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-07 05:22:36

我使用了长度(time.sleep),参数'length‘代表当前曲目的剩余持续时间。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64671057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档