Private GIT

Skip to content
Snippets Groups Projects
Commit 383ec7e6 authored by ikkemaniac's avatar ikkemaniac Committed by Ruud
Browse files

check for XBMC JSON-RPC version and improve logging info

parent dd911829
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,12 @@ class XBMC(Notification): ...@@ -18,6 +18,12 @@ class XBMC(Notification):
hosts = splitString(self.conf('host')) hosts = splitString(self.conf('host'))
successful = 0 successful = 0
for host in hosts: for host in hosts:
if listener == "test":
# XBMC JSON-RPC version request
response = self.request(host, [
('JSONRPC.Version', {})
])
else:
response = self.request(host, [ response = self.request(host, [
('GUI.ShowNotification', {"title":"CouchPotato", "message":message}), ('GUI.ShowNotification', {"title":"CouchPotato", "message":message}),
('VideoLibrary.Scan', {}), ('VideoLibrary.Scan', {}),
...@@ -25,8 +31,26 @@ class XBMC(Notification): ...@@ -25,8 +31,26 @@ class XBMC(Notification):
try: try:
for result in response: for result in response:
if result['result'] == "OK": if (listener != "test" and result['result'] == "OK"):
successful += 1 successful += 1
elif (listener == "test"):
if (type(result['result']['version']).__name__ == 'int'):
# fail, only v2 and v4 return an int object
# v6 (as of XBMC v12(Frodo)) is required to send notifications
xbmc_rpc_version = str(result['result']['version'])
log.error("XBMC JSON-RPC Version: %s ; Notifications only supported for v6 [as of XBMC v12(Frodo)]", xbmc_rpc_version)
return False
elif (type(result['result']['version']).__name__ == 'dict'):
# success, v6 returns an array object containing
# major, minor and patch number
xbmc_rpc_version = str(result['result']['version']['major'])
xbmc_rpc_version += "." + str(result['result']['version']['minor'])
xbmc_rpc_version += "." + str(result['result']['version']['patch'])
log.debug("XBMC JSON-RPC Version: %s", xbmc_rpc_version)
# ok, XBMC version is supported, send the text message
self.notify(message = message, data = {}, listener = 'test-rpcversion-ok')
return True
except: except:
log.error('Failed parsing results: %s', traceback.format_exc()) log.error('Failed parsing results: %s', traceback.format_exc())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment