1
0
mirror of https://github.com/moparisthebest/SickRage synced 2025-01-12 06:18:03 -05:00

Fix for XBMC notifier when XBMC has no shows in library.

This commit is contained in:
echel0n 2014-05-30 05:43:00 -07:00
parent 78c4211925
commit bea999b639

View File

@ -141,13 +141,15 @@ class XBMCNotifier:
else: else:
logger.log(u"Detected XBMC version >= 12, using XBMC JSON API", logger.DEBUG) logger.log(u"Detected XBMC version >= 12, using XBMC JSON API", logger.DEBUG)
command = '{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"%s","message":"%s", "image": "%s"},"id":1}' % ( command = '{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"%s","message":"%s", "image": "%s"},"id":1}' % (
title.encode("utf-8"), message.encode("utf-8"), self.sb_logo_url) title.encode("utf-8"), message.encode("utf-8"), self.sb_logo_url)
notifyResult = self._send_to_xbmc_json(command, curHost, username, password) notifyResult = self._send_to_xbmc_json(command, curHost, username, password)
if notifyResult: if notifyResult:
result += curHost + ':' + notifyResult["result"].decode(sickbeard.SYS_ENCODING) result += curHost + ':' + notifyResult["result"].decode(sickbeard.SYS_ENCODING)
else: else:
if sickbeard.XBMC_ALWAYS_ON or force: if sickbeard.XBMC_ALWAYS_ON or force:
logger.log(u"Failed to detect XBMC version for '" + curHost + "', check configuration and try again.", logger.ERROR) logger.log(
u"Failed to detect XBMC version for '" + curHost + "', check configuration and try again.",
logger.ERROR)
result += curHost + ':False' result += curHost + ':False'
return result return result
@ -191,7 +193,7 @@ class XBMCNotifier:
return False return False
############################################################################## # #############################################################################
# Legacy HTTP API (pre XBMC 12) methods # Legacy HTTP API (pre XBMC 12) methods
############################################################################## ##############################################################################
@ -281,7 +283,7 @@ class XBMCNotifier:
# use this to get xml back for the path lookups # use this to get xml back for the path lookups
xmlCommand = { xmlCommand = {
'command': 'SetResponseFormat(webheader;false;webfooter;false;header;<xml>;footer;</xml>;opentag;<tag>;closetag;</tag>;closefinaltag;false)'} 'command': 'SetResponseFormat(webheader;false;webfooter;false;header;<xml>;footer;</xml>;opentag;<tag>;closetag;</tag>;closefinaltag;false)'}
# sql used to grab path(s) # sql used to grab path(s)
sqlCommand = {'command': 'QueryVideoDatabase(%s)' % (pathSql)} sqlCommand = {'command': 'QueryVideoDatabase(%s)' % (pathSql)}
# set output back to default # set output back to default
@ -432,9 +434,12 @@ class XBMCNotifier:
# get tvshowid by showName # get tvshowid by showName
showsCommand = '{"jsonrpc":"2.0","method":"VideoLibrary.GetTVShows","id":1}' showsCommand = '{"jsonrpc":"2.0","method":"VideoLibrary.GetTVShows","id":1}'
showsResponse = self._send_to_xbmc_json(showsCommand, host) showsResponse = self._send_to_xbmc_json(showsCommand, host)
if (showsResponse == False):
if showsResponse and "result" in showsResponse and "tvshows" in showsResponse["result"]:
shows = showsResponse["result"]["tvshows"]
else:
logger.log(u"XBMC: No tvshows in XBMC TV show list", logger.DEBUG)
return False return False
shows = showsResponse["result"]["tvshows"]
for show in shows: for show in shows:
if (show["label"] == showName): if (show["label"] == showName):
@ -451,7 +456,7 @@ class XBMCNotifier:
# lookup tv-show path # lookup tv-show path
pathCommand = '{"jsonrpc":"2.0","method":"VideoLibrary.GetTVShowDetails","params":{"tvshowid":%d, "properties": ["file"]},"id":1}' % ( pathCommand = '{"jsonrpc":"2.0","method":"VideoLibrary.GetTVShowDetails","params":{"tvshowid":%d, "properties": ["file"]},"id":1}' % (
tvshowid) tvshowid)
pathResponse = self._send_to_xbmc_json(pathCommand, host) pathResponse = self._send_to_xbmc_json(pathCommand, host)
path = pathResponse["result"]["tvshowdetails"]["file"] path = pathResponse["result"]["tvshowdetails"]["file"]
@ -465,7 +470,7 @@ class XBMCNotifier:
logger.log(u"XBMC Updating " + showName + " on " + host + " at " + path, logger.DEBUG) logger.log(u"XBMC Updating " + showName + " on " + host + " at " + path, logger.DEBUG)
updateCommand = '{"jsonrpc":"2.0","method":"VideoLibrary.Scan","params":{"directory":%s},"id":1}' % ( updateCommand = '{"jsonrpc":"2.0","method":"VideoLibrary.Scan","params":{"directory":%s},"id":1}' % (
json.dumps(path)) json.dumps(path))
request = self._send_to_xbmc_json(updateCommand, host) request = self._send_to_xbmc_json(updateCommand, host)
if not request: if not request:
logger.log(u"Update of show directory failed on " + showName + " on " + host + " at " + path, logger.log(u"Update of show directory failed on " + showName + " on " + host + " at " + path,
@ -543,7 +548,9 @@ class XBMCNotifier:
return True return True
else: else:
if sickbeard.XBMC_ALWAYS_ON: if sickbeard.XBMC_ALWAYS_ON:
logger.log(u"Failed to detect XBMC version for '" + host + "', check configuration and try again.", logger.ERROR) logger.log(
u"Failed to detect XBMC version for '" + host + "', check configuration and try again.",
logger.ERROR)
result = result + 1 result = result + 1
# needed for the 'update xbmc' submenu command # needed for the 'update xbmc' submenu command