如何在 Python (Windows) 中获取 Spotify 当前播放的歌曲? [英] How to get Spotify current playing song in Python (Windows)?

查看:56
本文介绍了如何在 Python (Windows) 中获取 Spotify 当前播放的歌曲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to show the current playing song in Spotify on a 16x2 LCD. I was thinking of connecting the LCD with my Arduino and then making a Python script that sends the current playing song of Spotify to the Arduino.

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

To get to the point, I'm looking for a way to get Spotify's current playing song in Python. (I'm using Windows 8.) I found some ways like dbus, but they were either for Linux or for Mac.

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

Thanks in advance! (And sorry for bad English grammar.)

推荐答案

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

I encountered the same issue, so I wrote a library to solve this issue. The library can be found at github: https://github.com/XanderMJ/spotilib. Keep in mind that this is still work in progress.

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

Just copy the file and place it in your Python/Lib directory.

import spotilib
spotilib.artist() #returns the artist of the current playing song
spotilib.song() #returns the song title of the current playing song

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

spotilib.artist() returns only the first artist. I started working on an other library spotimeta.py to solve this issue. However, this is not working at 100% yet.

import spotimeta
spotimeta.artists() #returns a list of all the collaborating artists of the track

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

If an error occurs, spotimeta.artists() will return only the first artist (found with spotilib.artist())

希望这对您有所帮助(如果仍然需要)!

Hope this will help you (if still needed)!

这篇关于如何在 Python (Windows) 中获取 Spotify 当前播放的歌曲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆