EDIT : Let's try to clarify all this.
I'm writing a python script, and I want it to tell me the song that Spotify is currently playing.
I've tried looking for libraries that could help me but didn't find any that are still maintained and working.
I've also looked through Spotify's web API, but it does not provide any way to get that information.
The only potential solution I found would be to grab the title of my Spotify (desktop app) window. But I didn't manage to do that so far.
So basically, what I'm asking is whether anyone knows :
The Spotify client on Linux implements a D-Bus interface called MPRIS - Media Player Remote Interfacing Specification.
You could access the title (and other metadata) from python like this:
import dbus session_bus = dbus.SessionBus() spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2") spotify_properties = dbus.Interface(spotify_bus, "org.freedesktop.DBus.Properties") metadata = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "Metadata") # The property Metadata behaves like a python dict for key, value in metadata.items(): print key, value # To just print the title print metadata['xesam:title']