version = "0.3" __module_name__ = "XBMC Announcer" __module_version__ = version __module_description__ = "announces XBMC now playing" import sys,string,urllib,xchat #xboxIP = "192.168.1.250" # change this to your xbox's IP xboxIP = "127.0.0.1:8080" # change this to your xbox's IP def makeHttpRequest(command): try: u = urllib.urlopen('http://'+xboxIP+'/xbmcCmds/xbmcHttp?command='+command) except IOError, err: print " ERROR: Xbox isn't online", err return 0 else: u=u.readlines() line = u[0].lower() if line.count("error") > 0: print "server error" return 0 elif line.count("html") > 0: line = u[1].lower() if line.count("error") > 0: print "xbmc httpapi error" return 0 elif line.count("ok") > 0: # print "OK" return 1 elif line.count("[nothing playing]") > 0: print " XBMC isn't playing anything" return 0 else: return u def xbmcNP(word,wordeol,userdata): data = {} response=makeHttpRequest("getcurrentlyplaying") if response != 0: for i in response: try: key, val = i.strip().replace('