Named parameters and XBMC

Skip to first unread message

Jan 30, 2013, 4:28:19 PM1/30/13
Hello I'm trying to figure out how to use JSONRPClib with XBMC 12 Frodo (RC3). What I want to do is basically check what is happening in XBMC; if something is playing or if sleep mode is activated. I found on the XBMC forum that the following call should be correct to use for XBMC Frodo

{"params": { "booleans": ["library.isscanning"] }, "jsonrpc": "2.0", "method": "XBMC.GetInfoBooleans", "id": 1},

if I wish to check if the library scan function is active. My question to you is, how to translate this into a JSONRPClib call. I ran Introspect that gave me the following print out for 

>> intr = server.JSONRPC.Introspect()
>> print intr['methods']['XBMC.GetInfoBooleans']:

{u'params': [{u'minItems': 1, u'items': {u'type': u'string'}, u'required': True, u'type': u'array', u'name': u'booleans'}], u'returns': {u'additionalProperties': {u'default': u'', u'type': u'string'}, u'type': u'object', u'description': u'Object containing key-value pairs of the retrieved info booleans'}, u'type': u'method', u'description': u'Retrieve info booleans about XBMC and the system'}

I guess the start should be something along the lines of "server.XBMC.GetInfoBooleans", but I have no idea how to use the params...

Regards /Daniel

Clément Cloom

Nov 8, 2013, 4:05:39 AM11/8/13
Hello Daniel,

Did you figure this out? I want to do the same, I succeeded with another piece of code I have found there:

but I would like to use jsonrpclib to make the code easier to read and less complicated. I also want to use jsonrpclib to have a server running on my pi to switch on and off the light in my living room. Long story short I want a cinema button on my XBMC remote control to switch off the big lights and put the small ones when I run a movie :) I don't want to use different jsonrpc lib/scripts and jsonrpclib looks perfect for what I have to do.

So Daniel if you can help me here that would be much appreciated!

Here is the simple piece of code I tried:
>>> import jsonrpclib
>>> server = jsonrpclib.Server('')
>>> print server.Player.GetActivePlayers()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/jsonrpclib/", line 276, in __call__
    return self.__send(self.__name, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/jsonrpclib/", line 224, in _request
    response = self._run_request(request)
  File "/usr/local/lib/python2.7/dist-packages/jsonrpclib/", line 254, in _run_request
    return_obj = loads(response)
  File "/usr/local/lib/python2.7/dist-packages/jsonrpclib/", line 507, in loads
    result = jloads(data)
  File "/usr/local/lib/python2.7/dist-packages/jsonrpclib/", line 105, in jloads
    return json.loads(json_string)
  File "/usr/lib/python2.7/json/", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Reply all
Reply to author
0 new messages