a few more places we need to check for exceptions

This commit is contained in:
sfaulds 2016-12-01 15:28:42 +11:00
parent 4c9408b640
commit f793f709ef
4 changed files with 37 additions and 16 deletions

View file

@ -114,12 +114,13 @@ class DownloadUtils(object):
# Attempt at getting sessionId # Attempt at getting sessionId
url = "{server}/emby/Sessions?DeviceId=%s&format=json" % device_id url = "{server}/emby/Sessions?DeviceId=%s&format=json" % device_id
result = self.downloadUrl(url)
try: try:
result = self.downloadUrl(url)
session_id = result[0]['Id'] session_id = result[0]['Id']
except (KeyError, TypeError): except Exception as error:
log.error("Failed to retrieve the session id.") log.error("Failed to retrieve the session id: " + str(error))
else: else:
log.info("SessionId: %s", session_id) log.info("SessionId: %s", session_id)

View file

@ -58,9 +58,13 @@ class Embydb_Functions():
def getView_embyId(self, item_id): def getView_embyId(self, item_id):
# Returns ancestors using embyId # Returns ancestors using embyId
url = "{server}/emby/Items/%s/Ancestors?UserId={UserId}&format=json" % item_id url = "{server}/emby/Items/%s/Ancestors?UserId={UserId}&format=json" % item_id
view_list = self.download(url)
if view_list is None: try:
view_list = self.download(url)
except Exception as error:
log.info("Error getting views: " + str(error))
view_list = [] view_list = []
for view in view_list: for view in view_list:
if view['Type'] == "CollectionFolder": if view['Type'] == "CollectionFolder":

View file

@ -285,9 +285,9 @@ def addUser():
# Get session # Get session
url = "{server}/emby/Sessions?DeviceId=%s&format=json" % deviceId url = "{server}/emby/Sessions?DeviceId=%s&format=json" % deviceId
result = doUtils.downloadUrl(url)
try: try:
result = doUtils.downloadUrl(url)
sessionId = result[0]['Id'] sessionId = result[0]['Id']
additionalUsers = result[0]['AdditionalUsers'] additionalUsers = result[0]['AdditionalUsers']
# Add user to session # Add user to session
@ -365,8 +365,8 @@ def addUser():
icon="special://home/addons/plugin.video.emby/icon.png", icon="special://home/addons/plugin.video.emby/icon.png",
time=1000) time=1000)
except: except Exception as error:
log.error("Failed to add user to session.") log.error("Failed to add user to session: " + str(error))
dialog.notification( dialog.notification(
heading=lang(29999), heading=lang(29999),
message=lang(33068), message=lang(33068),
@ -381,10 +381,11 @@ def addUser():
window('EmbyAdditionalUserImage.%s' % i, clear=True) window('EmbyAdditionalUserImage.%s' % i, clear=True)
url = "{server}/emby/Sessions?DeviceId=%s&format=json" % deviceId url = "{server}/emby/Sessions?DeviceId=%s&format=json" % deviceId
result = doUtils.downloadUrl(url)
try: try:
result = doUtils.downloadUrl(url)
additionalUsers = result[0]['AdditionalUsers'] additionalUsers = result[0]['AdditionalUsers']
except (IndexError, KeyError, TypeError) as error: except Exception as error:
log.error(error) log.error(error)
additionalUsers = [] additionalUsers = []
@ -692,8 +693,13 @@ def createListItemFromEmbyItem(item,art=artwork.Artwork(),doUtils=downloadutils.
#listitem setup for pictures... #listitem setup for pictures...
img_path = allart.get('Primary') img_path = allart.get('Primary')
li.setProperty("path",img_path) li.setProperty("path",img_path)
picture = doUtils.downloadUrl("{server}/Items/%s/Images" %itemid) try:
if picture: picture = doUtils.downloadUrl("{server}/Items/%s/Images" %itemid)
except Exception as error:
lof.info("Error getting images from server: " + str(error))
picture = None
if picture is not None:
picture = picture[0] picture = picture[0]
if picture.get("Width") > picture.get("Height"): if picture.get("Width") > picture.get("Height"):
li.setArt( {"fanart": img_path}) #add image as fanart for use with skinhelper auto thumb/backgrund creation li.setArt( {"fanart": img_path}) #add image as fanart for use with skinhelper auto thumb/backgrund creation
@ -781,8 +787,13 @@ def BrowseChannels(itemid, folderid=None):
else: else:
url = "{server}/emby/Channels/%s/Items?UserId={UserId}&format=json" % itemid url = "{server}/emby/Channels/%s/Items?UserId={UserId}&format=json" % itemid
result = doUtils.downloadUrl(url) try:
if result and result.get("Items"): result = doUtils.downloadUrl(url)
except Exception as error:
log.info("Error getting channel: " + str(error))
result = None
if result is not None and result.get("Items"):
for item in result.get("Items"): for item in result.get("Items"):
itemid = item['Id'] itemid = item['Id']
itemtype = item['Type'] itemtype = item['Type']

View file

@ -87,7 +87,12 @@ class LibrarySync(threading.Thread):
if settings('serverSync') == "true": if settings('serverSync') == "true":
# Try to use fast start up # Try to use fast start up
url = "{server}/emby/Plugins?format=json" url = "{server}/emby/Plugins?format=json"
result = self.doUtils(url)
try:
result = self.doUtils(url)
except Exception as error:
log.info("Error getting plugin list form server: " + str(error))
result = []
for plugin in result: for plugin in result:
if plugin['Name'] == "Emby.Kodi Sync Queue": if plugin['Name'] == "Emby.Kodi Sync Queue":