Skip to content

Instantly share code, notes, and snippets.

@evanradcliffe
Created July 8, 2016 15:55
Show Gist options
  • Save evanradcliffe/843543686b00577cace21bc582e84733 to your computer and use it in GitHub Desktop.
Save evanradcliffe/843543686b00577cace21bc582e84733 to your computer and use it in GitHub Desktop.
Search Genius for the current playing Spotify song.
#!/usr/bin/env python
import webbrowser
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
song_name = metadata['xesam:title']
print "Searching " + song_name
webbrowser.open('http://genius.com/search?q=' + song_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment