Skip to content

Instantly share code, notes, and snippets.

@Hellowlol
Created July 11, 2014 00:39
Show Gist options
  • Save Hellowlol/08779a310be6e8c89071 to your computer and use it in GitHub Desktop.
Save Hellowlol/08779a310be6e8c89071 to your computer and use it in GitHub Desktop.
jsonrcp xmbc.
import json
import urllib2
import base64
def jsonrcp():
username = 'u'
password = 'p'
ip = '192.168.1.122'
port = '8080'
url = 'http://%s:%s/jsonrpc' % (ip, port)
cmd = {
'jsonrpc': '2.0',
'id': 0,
'method': 'Addons.ExecuteAddon',
'params': {
'addonid': 'plugin.video.nrk',
'params': {
'path' : '/category/barn'
}
}
}
data = json.JSONEncoder().encode(cmd)
content_length = len(data)
content = {
'Content-Type': 'application/json',
'Content-Length': content_length,
}
request = urllib2.Request(url, data, content)
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
f = urllib2.urlopen(request)
response = f.read()
f.close()
response = json.JSONDecoder().decode(response)
print response
jsonrcp()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment