A python script, that monitors the dbus of Spotify and writes currently playing songs to a file, mainly for streaming purposes
"Spotireader" hooks to the DBus-Signal PropertiesChanged of org.freedesktop.DBus.Properties to monitor changes of
org.mpris.MediaPlayer2.spotify and writes song name and artist to a file
- dbus
- glib
For Archusers:
sudo pacman -S dbus glib2
We also need some dependencies from AUR so go on and use your favorite AUR package manager (in my case yay)
yay -S python-dbus python-dbus-common python-gobject python-gobject2
that should be all
SONG_FILE = "PATH"and set PATH to whatever file you want (file not directory).
And youre ready to go, hookup Spotify and execute spotireader.py
If you have experience with Python or would like to play around, here is a JSON Representation of the
b Parameter (Dictionary)
of the Handler function:
{"Metadata":
{
"mpris:trackid": "spotify:track:48Q3snZ8muPxDrZooxj3jB",
"mpris:length": 182000000,
"mpris:artUrl": "https://open.spotify.com/image/fd7d53574408812ff207362180d4c9b7e7c8eab0",
"xesam:album": "Inspiration",
"xesam:albumArtist": ["Unknown Brain"],
"xesam:artist": ["Unknown Brain"],
"xesam:autoRating": 0.58,
"xesam:discNumber": 1,
"xesam:title": "Inspiration",
"xesam:trackNumber": 1,
"xesam:url":
"https://open.spotify.com/track/48Q3snZ8muPxDrZooxj3jB"},
"PlaybackStatus": "Playing"
}
}
Should you encounter any problems, feel free to open a new issue
i will do my best to help you resolve your problem