Last active
December 30, 2016 16:19
-
-
Save sours/5869011 to your computer and use it in GitHub Desktop.
Simple windows spotify xchat plugin.
This file contains hidden or 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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! I've modified it a bit so it works with Hexchat (https://hexchat.github.io/): https://gist.github.com/ramiro/c43767836ba026b2fd79d45347507cb1