Add JSONRPC class
This commit is contained in:
parent
3a859279ec
commit
51400fd828
1 changed files with 30 additions and 0 deletions
|
@ -51,6 +51,36 @@ def language(string_id):
|
||||||
# Central string retrieval - unicode
|
# Central string retrieval - unicode
|
||||||
return xbmcaddon.Addon(id='plugin.video.emby').getLocalizedString(string_id)
|
return xbmcaddon.Addon(id='plugin.video.emby').getLocalizedString(string_id)
|
||||||
|
|
||||||
|
class JSONRPC(object):
|
||||||
|
|
||||||
|
id_ = 1
|
||||||
|
jsonrpc = "2.0"
|
||||||
|
|
||||||
|
def __init__(self, method, **kwargs):
|
||||||
|
|
||||||
|
self.method = method
|
||||||
|
|
||||||
|
for arg in kwargs: # id_(int), jsonrpc(str)
|
||||||
|
self.arg = arg
|
||||||
|
|
||||||
|
def _query(self):
|
||||||
|
|
||||||
|
query = {
|
||||||
|
|
||||||
|
'jsonrpc': self.jsonrpc,
|
||||||
|
'id': self.id_,
|
||||||
|
'method': self.method,
|
||||||
|
}
|
||||||
|
if self.params is not None:
|
||||||
|
query['params'] = self.params
|
||||||
|
|
||||||
|
return json.dumps(query)
|
||||||
|
|
||||||
|
def execute(self, params=None):
|
||||||
|
|
||||||
|
self.params = params
|
||||||
|
return json.loads(xbmc.executeJSONRPC(self._query()))
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
# Database related methods
|
# Database related methods
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue