Created
November 20, 2018 22:36
-
-
Save bodziek666/c5506ddb25a5ef5ec6e9bccd1a95be75 to your computer and use it in GitHub Desktop.
python3 - spotify dbus example
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/env python3 | |
import dbus | |
def main(): | |
bus = dbus.SessionBus() | |
spotify = dbus.Interface(bus.get_object('org.mpris.MediaPlayer2.spotify', '/org/mpris/MediaPlayer2'), dbus_interface='org.freedesktop.DBus.Properties') | |
track_data = spotify.Get('org.mpris.MediaPlayer2.Player', 'Metadata') | |
track_url = track_data.get('xesam:url') | |
print(track_url) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment