Skip to content

Instantly share code, notes, and snippets.

@sours
Last active December 30, 2016 16:19
Show Gist options
  • Save sours/5869011 to your computer and use it in GitHub Desktop.
Save sours/5869011 to your computer and use it in GitHub Desktop.
Simple windows spotify xchat plugin.
import xchat
import win32gui
__module_name__ = "Spotify"
__module_version__ = "1.0"
__module_description__ = "Spotify now playing"
xchat.prnt("Loaded %s version %s" % (__module_name__, __module_version__))
def spotify(word, wordeol, userdata):
hwnd = win32gui.FindWindow("SpotifyMainWindow", None)
if not hwnd:
xchat.prnt("Spotify is not running")
return xchat.EAT_ALL
text = win32gui.GetWindowText(hwnd)
if len(text) <= 0:
xchat.prnt("No title found")
return xchat.EAT_ALL
if text == "Spotify":
xchat.prnt("No track playing")
return xchat.EAT_ALL
xchat.command("say %s -" % (text.split("Spotify - ")[1]))
return xchat.EAT_ALL
def unload_cb(userdata):
xchat.prnt("Unloaded %s" % (__module_name__,))
xchat.hook_command("spotify", spotify, help="/spotify - Spotify now playing")
xchat.hook_unload(unload_cb)
@ramiro
Copy link

ramiro commented Dec 30, 2016

Thanks for this! I've modified it a bit so it works with Hexchat (https://hexchat.github.io/): https://gist.github.com/ramiro/c43767836ba026b2fd79d45347507cb1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment