Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib, urllib2
- import base64
- import re
- ##XBMC Host Info##
- host = ""
- username = ''
- password = ''
- #####
- event = eg.event.suffix
- parts = event.split("::")
- #########Incoming Call Handling##########
- if parts[2] == "CallAccept":
- baseUrl = "http://" + host + "/xbmcCmds/xbmcHttp?command="
- cmd = "getcurrentlyplaying"
- url = baseUrl + cmd
- req = urllib2.Request(url)
- if password != '':
- base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
- authheader = "Basic %s" % base64string
- req.add_header("Authorization", authheader)
- handle = urllib2.urlopen(req, timeout=10)
- text = handle.read()
- handle.close()
- text = re.sub(r'<[^>]*?>', '', text)
- if text.find("Type:Video") != -1 and text.find("PlayStatus:Playing") != -1:
- print "Pause XBMC Video"
- eg.plugins.XBMC.Pause()
- if text.find("Type:Audio") != -1 and text.find("PlayStatus:Playing") != -1:
- print "Lower Volume"
- eg.plugins.System.SetMasterVolume(18.0, 0)
- #########Call End Handling##########
- if parts[2] == "CallEnd":
- baseUrl = "http://" + host + "/xbmcCmds/xbmcHttp?command="
- cmd = "getcurrentlyplaying"
- url = baseUrl + cmd
- req = urllib2.Request(url)
- if password != '':
- base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
- authheader = "Basic %s" % base64string
- req.add_header("Authorization", authheader)
- handle = urllib2.urlopen(req, timeout=10)
- text = handle.read()
- handle.close()
- text = re.sub(r'<[^>]*?>', '', text)
- if text.find("Type:Video") != -1 and text.find("PlayStatus:Paused") != -1:
- print "Resume XBMC Video"
- eg.plugins.XBMC.Play()
- if text.find("Type:Audio") != -1 and text.find("PlayStatus:Playing") != -1:
- print "Raise Volume"
- eg.plugins.System.SetMasterVolume(100.0, 0)
- #########CallDialed Handling##########
- if parts[2] == "CallDialed":
- baseUrl = "http://" + host + "/xbmcCmds/xbmcHttp?command="
- cmd = "getcurrentlyplaying"
- url = baseUrl + cmd
- req = urllib2.Request(url)
- if password != '':
- base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
- authheader = "Basic %s" % base64string
- req.add_header("Authorization", authheader)
- handle = urllib2.urlopen(req, timeout=10)
- text = handle.read()
- handle.close()
- text = re.sub(r'<[^>]*?>', '', text)
- if text.find("Type:Video") != -1 and text.find("PlayStatus:Playing") != -1:
- print "Pause XBMC Video"
- eg.plugins.XBMC.Pause()
- if text.find("Type:Audio") != -1 and text.find("PlayStatus:Playing") != -1:
- print "Lower Volume"
- eg.plugins.System.SetMasterVolume(18.0, 0)
- #########SMS Handling#########
- if parts[2] == "SMS":
- if parts[3] == "REPLACE THIS TEXT WITH CONTACT NAME":
- if parts[4] == "Xbmc":
- eg.plugins.System.Execute(u'C:\\Program Files (x86)\\XBMC\\XBMC.exe', u'', 0, False, 2, u'')
- if parts[3] == "REPLACE THIS TEXT WITH CONTACT NAME":
- if parts[4] == "Hibernate":
- eg.plugins.System.Hibernate(True)
- if parts[3] == "REPLACE THIS TEXT WITH CONTACT NAME":
- if parts[4] == "PC Off":
- eg.plugins.System.PowerDown(True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement