如何在 Python (Windows) 中获取 Spotify 当前播放的歌曲?

Kev*_*vin 0 python arduino spotify python-3.x

我想在 16x2 LCD 上显示 Spotify 中当前播放的歌曲。我正在考虑将 LCD 与我的 Arduino 连接,然后制作一个 Python 脚本,将 Spotify 当前播放的歌曲发送到 Arduino。

为了切入正题,我正在寻找一种在 Python 中获取 Spotify 当前播放歌曲的方法。(我使用的是 Windows 8。)我找到了一些类似 dbus 的方法,但它们要么适用于 Linux,要么适用于 Mac。

提前致谢!(抱歉英语语法不好。)

小智 5

我遇到了同样的问题,所以我写了一个库来解决这个问题。该库可以在 github 上找到:https : //github.com/XanderMJ/spotilib。请记住,这仍在进行中。

只需复制该文件并将其放置在您的 Python/Lib 目录中即可。

import spotilib
spotilib.artist() #returns the artist of the current playing song
spotilib.song() #returns the song title of the current playing song
Run Code Online (Sandbox Code Playgroud)

spotilib.artist() 只返回第一位艺术家。我开始研究另一个库spotimeta.py来解决这个问题。但是,这还没有达到 100%。

import spotimeta
spotimeta.artists() #returns a list of all the collaborating artists of the track
Run Code Online (Sandbox Code Playgroud)

如果发生错误,spotimeta.artists()将只返回第一个艺术家(通过spotilib.artist()找到)

希望这会帮助你(如果仍然需要)!