Skip to content

Instantly share code, notes, and snippets.

@daktak
Created April 22, 2014 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daktak/11163212 to your computer and use it in GitHub Desktop.
Save daktak/11163212 to your computer and use it in GitHub Desktop.
Send notify popup to XBMC
#!/bin/env python2
import json
import requests
import getopt, sys
HOST='localhost'
PORT='8080'
TITLE="Testing"
MESSAGE="Hello"
options, remainder = getopt.getopt(sys.argv[1:], 'h:p:t:m:', ['host=','port=','title=','message='])
for opt, arg in options:
if opt in ('-h','--host'):
HOST = arg
elif opt in ('-p','--port'):
PORT = arg
elif opt in ('-t','--title'):
TITLE = arg
elif opt in ('-m','--message'):
MESSAGE = arg
message = {'jsonrpc':'2.0','method':'GUI.ShowNotification','params':{'title':TITLE,'message':MESSAGE},'id':1}
jsons = json.dumps(message)
url = "http://"+HOST+":"+PORT+"/jsonrpc?request="
#headers = {'content-type': 'application/json' }
#r = requests.get(url, data=message, headers=headers)
r = requests.get(url+jsons)
#print (url)
if r.status_code == 200:
print (json.loads(r.content)["result"])
elif r.status_code !=404:
print (json.loads(r.content)["message"])
else:
print (r.status_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment