Skip to content

Instantly share code, notes, and snippets.

@sputnikus
Forked from sonicrules1234/nowplaying.py
Last active December 30, 2015 20:08
Show Gist options
  • Save sputnikus/7878323 to your computer and use it in GitHub Desktop.
Save sputnikus/7878323 to your computer and use it in GitHub Desktop.

Revisions

  1. sputnikus revised this gist Dec 9, 2013. 1 changed file with 24 additions and 24 deletions.
    48 changes: 24 additions & 24 deletions nowplaying.py
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,30 @@
    import xchat, urllib, re
    import xchat, re, requests
    from requests.auth import HTTPBasicAuth
    __module_name__ = "vlcnowplaying"
    __module_version__ = "1.0"
    __module_description__ = "sonicrules1234's Now playing script for vlc"

    __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\>""")
    \<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) :
    x = urllib.urlopen("http://127.0.0.1:8080/requests/status.xml")
    xml = x.read()
    x.close()
    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],\
  2. @sonicrules1234 sonicrules1234 created this gist Mar 23, 2011.
    38 changes: 38 additions & 0 deletions nowplaying.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    import xchat, urllib, re
    __module_name__ = "vlcnowplaying"
    __module_version__ = "1.0"
    __module_description__ = "sonicrules1234's 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) :
    x = urllib.urlopen("http://127.0.0.1:8080/requests/status.xml")
    xml = x.read()
    x.close()
    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")})