-
-
Save sputnikus/7878323 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
import xchat, re, requests | |
from requests.auth import HTTPBasicAuth | |
__module_name__ = "vlcnowplaying" | |
__module_version__ = "1.1" | |
__module_description__ = "sputnikus' Now playing script for vlc" | |
metare = re.compile("""<meta\-information\> | |
\<title\>\<\!\[CDATA\[(.*)\]\]\>\<\/title\> | |
\<artist\>\<\!\[CDATA\[(.*)\]\]\>\<\/artist\> | |
\<genre\>\<\!\[CDATA\[(.*)\]\]\>\<\/genre\> | |
\<copyright\>\<\!\[CDATA\[(.*)\]\]\>\<\/copyright\> | |
\<album\>\<\!\[CDATA\[(.*)\]\]\>\<\/album\> | |
\<track\>\<\!\[CDATA\[(\d*)\]\]\>\<\/track\> | |
\<description\><\!\[CDATA\[(.*)\]\]\>\<\/description\> | |
\<rating\>\<\!\[CDATA\[(.*)\]\]\>\<\/rating\> | |
\<date\>\<\!\[CDATA\[(.*)\]\]\>\<\/date\> | |
\<url\>\<\!\[CDATA\[(.*)\]\]\>\<\/url\> | |
\<language\>\<\!\[CDATA\[(.*)\]\]\>\<\/language\> | |
\<now\_playing\>\<\!\[CDATA\[(.*)\]\]\>\<\/now\_playing\> | |
\<publisher\>\<\!\[CDATA\[(.*)\]\]\>\<\/publisher\> | |
\<encoded\_by\>\<\!\[CDATA\[(.*)\]\]\>\<\/encoded\_by\> | |
\<art\_url\>\<\!\[CDATA\[(.*)\]\]\>\<\/art\_url\> | |
\<track\_id\>\<\!\[CDATA\[(.*)\]\]\>\<\/track\_id\> | |
\<\/meta\-information\>""") | |
def on_NowPlaying(word, word_eol, userdata) : | |
response = request.get("http://127.0.0.1:8080/requests/status.xml", auth=HTTPBasicAuth('', '<your http password>')) | |
xml = x.text() | |
regex = userdata["regex"] | |
groups = regex.search(xml).groups() | |
data = dict(title=groups[0], artist=groups[1], genre=groups[2],\ | |
cpyright=groups[3], album=groups[4], track=groups[5],\ | |
description=groups[6], rating=groups[7], date=groups[8],\ | |
url=groups[9], language=groups[10], now_playing=groups[11],\ | |
publisher=groups[12], encoded_by=groups[13], art_url=groups[14],\ | |
track_id=groups[15]) | |
xchat.command("me is now playing \x02%(title)s from the album %(album)s by %(artist)s.\x02" % dict(channel=userdata["context"], title=data["title"], album=data["album"], artist=data["artist"])) | |
return xchat.EAT_ALL | |
xchat.hook_command("NP", on_NowPlaying, userdata={"regex":metare, "context":xchat.get_info("channel")}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment