本文整理匯總了Python中xbmc.executeJSONRPC方法的典型用法代碼示例。如果您正苦於以下問題:Python xbmc.executeJSONRPC方法的具體用法?Python xbmc.executeJSONRPC怎麽用?Python xbmc.executeJSONRPC使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xbmc
的用法示例。
在下文中一共展示了xbmc.executeJSONRPC方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: jsonrpc
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def jsonrpc(*args, **kwargs):
"""Perform JSONRPC calls"""
from json import dumps, loads
# We do not accept both args and kwargs
if args and kwargs:
log(4, 'ERROR: Wrong use of jsonrpc()')
return None
# Process a list of actions
if args:
for (idx, cmd) in enumerate(args):
if cmd.get('id') is None:
cmd.update(id=idx)
if cmd.get('jsonrpc') is None:
cmd.update(jsonrpc='2.0')
return loads(xbmc.executeJSONRPC(dumps(args)))
# Process a single action
if kwargs.get('id') is None:
kwargs.update(id=0)
if kwargs.get('jsonrpc') is None:
kwargs.update(jsonrpc='2.0')
return loads(xbmc.executeJSONRPC(dumps(kwargs)))
示例2: getEpisodeTVDB
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def getEpisodeTVDB(self, xbmc_id):
rpccmd = {'jsonrpc': '2.0', 'method': 'VideoLibrary.GetEpisodeDetails', 'params': {"episodeid": int(xbmc_id), 'properties': ['season', 'episode', 'tvshowid', 'showtitle', 'uniqueid']}, 'id': 1}
rpccmd = json.dumps(rpccmd)
result = xbmc.executeJSONRPC(rpccmd)
result = json.loads(result)
log('result=%s' % result)
log('episode_id=%s' % result['result']['episodedetails']['uniqueid']['unknown'])
try:
item = {}
item['season'] = result['result']['episodedetails']['season']
item['tvshowid'] = result['result']['episodedetails']['tvshowid']
item['episode'] = result['result']['episodedetails']['episode']
item['showtitle'] = result['result']['episodedetails']['showtitle']
item['episode_id'] = result['result']['episodedetails']['uniqueid']['unknown']
return item
except:
return False
示例3: readLibretroCores
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def readLibretroCores():
Logutil.log("readLibretroCores", util.LOG_LEVEL_INFO)
addons = []
addonsJson = xbmc.executeJSONRPC(
'{ "jsonrpc": "2.0", "id": 1, "method": "Addons.GetAddons", "params": { "type": "kodi.gameclient" } }')
jsonResult = json.loads(addonsJson)
Logutil.log("readLibretroCores: jsonresult = " + str(jsonResult), util.LOG_LEVEL_INFO)
if str(list(jsonResult.keys())).find('error') >= 0:
Logutil.log("Error while reading gameclient addons via json. Assume that we are not in RetroPlayer branch.",
util.LOG_LEVEL_WARNING)
return False, None
try:
for addonObj in jsonResult[u'result'][u'addons']:
addonid = addonObj[u'addonid']
addons.append(addonid)
except KeyError:
#no addons installed or found
return True, addons
Logutil.log("addons: %s" % str(addons), util.LOG_LEVEL_INFO)
return True, addons
示例4: _edit_db_string
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def _edit_db_string( self,preset,type,label ):
keyboard = xbmc.Keyboard(preset)
keyboard.doModal()
if (keyboard.isConfirmed()):
try:
InputLabel=keyboard.getText()
conv=time.strptime(InputLabel,"%d/%m/%Y")
# InputLabel = Time.strftime('%Y-%m-%d')
InputLabel = time.strftime("%Y-%m-%d",conv)
except Exception:
sys.exc_clear()
if ((type == "Song") or (type == "Album") or (type == "Artist")):
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "AudioLibrary.Set%sDetails", "params": { "%s": "%s", "%sid":%s }}' % (type,label,InputLabel,type.lower(),self.DBID))
else:
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.Set%sDetails", "params": { "%s": "%s", "%sid":%s }}' % (type,label,InputLabel,type.lower(),self.DBID))
else:
return ""
示例5: json_rpc
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def json_rpc(method, params=None):
"""
Executes a JSON-RPC in Kodi
:param method: The JSON-RPC method to call
:type method: string
:param params: The parameters of the method call (optional)
:type params: dict
:returns: dict -- Method call result
"""
request_data = {'jsonrpc': '2.0', 'method': method, 'id': 1,
'params': params or {}}
request = json.dumps(request_data)
debug('Executing JSON-RPC: {}', request)
raw_response = xbmc.executeJSONRPC(request)
# debug('JSON-RPC response: {}'.format(raw_response))
response = json.loads(raw_response)
if 'error' in response:
raise IOError('JSONRPC-Error {}: {}'
.format(response['error']['code'],
response['error']['message']))
return response['result']
示例6: json_rpc_multi
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def json_rpc_multi(method, list_params=None):
"""
Executes multiple JSON-RPC with the same method in Kodi
:param method: The JSON-RPC method to call
:type method: string
:param list_params: Multiple list of parameters of the method call
:type list_params: a list of dict
:returns: dict -- Method call result
"""
request_data = [{'jsonrpc': '2.0', 'method': method, 'id': 1, 'params': params or {}} for params in list_params]
request = json.dumps(request_data)
debug('Executing JSON-RPC: {}', request)
raw_response = xbmc.executeJSONRPC(request)
if 'error' in raw_response:
raise IOError('JSONRPC-Error {}'.format(raw_response))
return json.loads(raw_response)
示例7: addon_updates
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def addon_updates(do=None):
setting = '"general.addonupdates"'
if do == 'set':
query = '{{"jsonrpc":"2.0", "method":"Settings.GetSettingValue","params":{{"setting":{0}}}, "id":1}}'.format(setting)
response = xbmc.executeJSONRPC(query)
match = re.compile('{"value":(.+?)}').findall(response)
if len(match) > 0:
default = match[0]
else:
default = 0
CONFIG.set_setting('default.addonupdate', str(default))
query = '{{"jsonrpc":"2.0", "method":"Settings.SetSettingValue","params":{{"setting":{0},"value":{1}}}, "id":1}}'.format(setting, '2')
response = xbmc.executeJSONRPC(query)
elif do == 'reset':
try:
value = int(float(CONFIG.get_setting('default.addonupdate')))
except:
value = 0
if value not in [0, 1, 2]:
value = 0
query = '{{"jsonrpc":"2.0", "method":"Settings.SetSettingValue","params":{{"setting":{0},"value":{1}}}, "id":1}}'.format(setting, value)
response = xbmc.executeJSONRPC(query)
示例8: look_and_feel_data
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def look_and_feel_data(do='save'):
from resources.libs.common import logging
scan = ['lookandfeel.enablerssfeeds', 'lookandfeel.font', 'lookandfeel.rssedit', 'lookandfeel.skincolors',
'lookandfeel.skintheme', 'lookandfeel.skinzoom', 'lookandfeel.soundskin', 'lookandfeel.startupwindow',
'lookandfeel.stereostrength']
if do == 'save':
for item in scan:
query = '{{"jsonrpc":"2.0", "method":"Settings.GetSettingValue","params":{{"setting":"{0}"}}, "id":1}}'.format(item)
response = xbmc.executeJSONRPC(query)
if 'error' not in response:
match = re.compile('{"value":(.+?)}').findall(str(response))
CONFIG.set_setting(item.replace('lookandfeel', 'default'), match[0])
logging.log("%s saved to %s" % (item, match[0]))
elif do == 'restore':
for item in scan:
value = CONFIG.get_setting(item.replace('lookandfeel', 'default'))
query = '{{"jsonrpc":"2.0", "method":"Settings.SetSettingValue","params":{{"setting":"{0}","value":{1}}}, "id":1}}'.format(item, value)
response = xbmc.executeJSONRPC(query)
logging.log("{0} restored to {1}".format(item, value))
示例9: mediaPlaying
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def mediaPlaying(): #TODO: make sure we're checking for all media
return StreamUtils.isPlaying()
# xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"Playlist.Clear","params":{"playlistid":1}}')
# xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"Playlist.Add","params":{"playlistid":1,"item":{"file":"' + str(url) + '"}}}')
# return xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"Player.Open","params":{"item":{"playlistid":1,"position":0}}}')
'''{u'iden': u'ujxCHwc6fiSsjAl11HK7y0',
u'created': 1411009240.141888,
u'receiver_email': u'ruuk25@gmail.com',
u'items': [],
u'target_device_iden': u'ujxCHwc6fiSsjz477zOU0a',
u'file_url': u'https://s3.amazonaws.com/pushbullet-uploads/ujxCHwc6fiS-wnH7qXNVOruppCCglRlC6iUXWHWR5xEV/IMG_20140827_164312.jpg',
u'modified': 1411009240.149686, u'dismissed': False,
u'sender_email_normalized': u'ruuk25@gmail.com',
u'file_type': u'image/jpeg',
u'image_url': u'https://pushbullet.imgix.net/ujxCHwc6fiS-wnH7qXNVOruppCCglRlC6iUXWHWR5xEV/IMG_20140827_164312.jpg',
u'sender_email': u'ruuk25@gmail.com',
u'file_name': u'IMG_20140827_164312.jpg',
u'active': True,
u'receiver_iden': u'ujxCHwc6fiS',
u'sender_iden': u'ujxCHwc6fiS',
u'type': u'file',
u'receiver_email_normalized': u'ruuk25@gmail.com'}'''
示例10: executeJSONRPCMethod
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def executeJSONRPCMethod(method, params={}):
rpc = {
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': 1
}
# Check if is there is an active player
activePlayers = executeJSONRPC('{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}')
if len(activePlayers) > 0:
del activePlayers[0]['type']
rpc['params'].update(activePlayers[0])
if method == 'Player.GoTo':
rpc['params'].setdefault('to', 'next')
from json import dumps
return executeJSONRPC(dumps(rpc))
return False
示例11: get_directory
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def get_directory( directory ):
request = {'jsonrpc': '2.0',
'method': 'Files.GetDirectory',
'params': {'properties': ['title', 'genre', 'year', 'rating', 'runtime', 'plot', 'file', 'art'],
'directory': directory,
'media': 'files'},
'id': 1
}
response = xbmc.executeJSONRPC(json.dumps(request))
j = json.loads(response)
result = j.get('result')
if result:
files = result.get('files', [])
else:
files = []
return files
示例12: get_addons
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def get_addons():
request = {'jsonrpc': '2.0',
'method': 'Addons.GetAddons',
'params': {'type': 'xbmc.addon.video',
'content': 'video',
'enabled': True,
'properties': ['name', 'fanart', 'thumbnail', 'description']},
'id': 1
}
response = xbmc.executeJSONRPC(json.dumps(request))
j = json.loads(response)
result = j.get('result')
if result:
addons = result.get('addons', [])
else:
addons = []
return addons
示例13: getStereoscopicMode
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def getStereoscopicMode():
"""
Retrieves stereoscopic mode from json-rpc
@return: "off", "split_vertical", "split_horizontal", "row_interleaved", "hardware_based", "anaglyph_cyan_red",
"anaglyph_green_magenta", "monoscopic"
@rtype: str
"""
query = '{"jsonrpc": "2.0", "method": "GUI.GetProperties", "params": {"properties": ["stereoscopicmode"]}, "id": 1}'
result = xbmc.executeJSONRPC(query)
jsonr = jloads(result)
ret = ''
if 'result' in jsonr:
if 'stereoscopicmode' in jsonr['result']:
if 'mode' in jsonr['result']['stereoscopicmode']:
ret = jsonr['result']['stereoscopicmode']['mode'].encode('utf-8')
return ret
示例14: getInfo
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def getInfo(self):
tries = 0
while tries < 8 and self.isPlaying() is False:
xbmc.sleep(250)
try:
player = json.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}'))
except RuntimeError:
playerid = -1
playertype = 'none'
else:
try:
playerid = player['result'][0]['playerid']
playertype = player['result'][0]['type']
except KeyError:
playerid = -1
playertype = 'none'
if playertype == 'audio':
self.getAudioInfo(playerid)
self.rectifyUnknowns()
elif playertype == 'video':
self.getVideoInfo(playerid)
self.rectifyUnknowns()
else:
self.info = {}
示例15: getWebserverInfo
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import executeJSONRPC [as 別名]
def getWebserverInfo():
json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Settings.getSettings", "params":'
' {"filter":{"section":"services", "category":"webserver"}}}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = json.loads(json_query)
if json_response.has_key('result') and json_response['result'].has_key('settings') and json_response['result']['settings'] is not None:
serverEnabled = False
serverPort = 8080
serverUser = ''
serverPassword = ''
for item in json_response['result']['settings']:
if item["id"] == u"services.webserver":
if item["value"] is True:
serverEnabled = True
elif item["id"] == u'services.webserverport':
serverPort = item['value']
elif item['id'] == u'services.webserverusername':
serverUser = item['value']
elif item['id'] == u'services.webserverpassword':
serverPassword = item['value']
return serverEnabled, serverPort, serverUser, serverPassword