diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index 7c23b5ab..e5cb5a1b 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -114,12 +114,13 @@ class DownloadUtils(object): # Attempt at getting sessionId url = "{server}/emby/Sessions?DeviceId=%s&format=json" % device_id - result = self.downloadUrl(url) + try: + result = self.downloadUrl(url) session_id = result[0]['Id'] - except (KeyError, TypeError): - log.error("Failed to retrieve the session id.") + except Exception as error: + log.error("Failed to retrieve the session id: " + str(error)) else: log.info("SessionId: %s", session_id) diff --git a/resources/lib/embydb_functions.py b/resources/lib/embydb_functions.py index dd4ca55f..aec9043b 100644 --- a/resources/lib/embydb_functions.py +++ b/resources/lib/embydb_functions.py @@ -58,9 +58,13 @@ class Embydb_Functions(): def getView_embyId(self, item_id): # Returns ancestors using embyId 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 = [] + for view in view_list: if view['Type'] == "CollectionFolder": diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 787d4fa0..003900b2 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -285,9 +285,9 @@ def addUser(): # Get session url = "{server}/emby/Sessions?DeviceId=%s&format=json" % deviceId - result = doUtils.downloadUrl(url) - + try: + result = doUtils.downloadUrl(url) sessionId = result[0]['Id'] additionalUsers = result[0]['AdditionalUsers'] # Add user to session @@ -365,8 +365,8 @@ def addUser(): icon="special://home/addons/plugin.video.emby/icon.png", time=1000) - except: - log.error("Failed to add user to session.") + except Exception as error: + log.error("Failed to add user to session: " + str(error)) dialog.notification( heading=lang(29999), message=lang(33068), @@ -381,10 +381,11 @@ def addUser(): window('EmbyAdditionalUserImage.%s' % i, clear=True) url = "{server}/emby/Sessions?DeviceId=%s&format=json" % deviceId - result = doUtils.downloadUrl(url) + try: + result = doUtils.downloadUrl(url) additionalUsers = result[0]['AdditionalUsers'] - except (IndexError, KeyError, TypeError) as error: + except Exception as error: log.error(error) additionalUsers = [] @@ -692,8 +693,13 @@ def createListItemFromEmbyItem(item,art=artwork.Artwork(),doUtils=downloadutils. #listitem setup for pictures... img_path = allart.get('Primary') li.setProperty("path",img_path) - picture = doUtils.downloadUrl("{server}/Items/%s/Images" %itemid) - if picture: + try: + 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] if picture.get("Width") > picture.get("Height"): 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: url = "{server}/emby/Channels/%s/Items?UserId={UserId}&format=json" % itemid - result = doUtils.downloadUrl(url) - if result and result.get("Items"): + try: + 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"): itemid = item['Id'] itemtype = item['Type'] diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index c560b8dd..6d4fe5b6 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -87,7 +87,12 @@ class LibrarySync(threading.Thread): if settings('serverSync') == "true": # Try to use fast start up 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: if plugin['Name'] == "Emby.Kodi Sync Queue":