Created
February 4, 2018 19:51
-
-
Save mcrmonkey/79d86e0de4fa915ef47ec8955290fad0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
## from https://raw.githubusercontent.com/carlasouza/.i3/master/.i3/i3blocks/spotify | |
# All credits to http://blog.abhijeetr.com/2012/02/spotify-changing-and-displaying-song.html | |
import dbus | |
bus = dbus.SessionBus() | |
player = bus.get_object('com.spotify.qt', '/') | |
iface = dbus.Interface(player, 'org.freedesktop.MediaPlayer2') | |
info = iface.GetMetadata() | |
# OUT: [dbus.String(u'xesam:album'), dbus.String(u'xesam:title'), dbus.String(u'xesam:trackNumber'), dbus.String(u'xesam:artist'), dbus.String(u'xesam:discNumber'), dbus.String(u'mpris:trackid'), dbus.String(u'mpris:length'), dbus.String(u'mpris:artUrl'), dbus.String(u'xesam:autoRating'), dbus.String(u'xesam:contentCreated'), dbus.String(u'xesam:url')] | |
print str(info['xesam:artist'][0]) + " - " + str(info['xesam:title']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment