Search code examples
pythonpython-3.xarduinospotify

How to get Spotify current playing song in Python (Windows)?


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.

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.)


Solution

  • 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.

    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() 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
    

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

    Hope this will help you (if still needed)!