From c8b050704baf81fcd644bfd43e1232cf6dccaf39 Mon Sep 17 00:00:00 2001 From: echel0n Date: Sat, 13 Dec 2014 04:14:29 -0800 Subject: [PATCH] Fixed issue with theTVDB IndexerAPI _parseActors method improperly parsing the data returned from the api causing an exception to occur during metadata refreshes. Fixed issues with Backup/Restore. Fixed issues with banners, posters, images via showPoster method. --- gui/slick/js/configBackupRestore.js | 4 ++-- lib/tvdb_api/tvdb_api.py | 18 ++++++++++-------- sickbeard/metadata/kodi_12plus.py | 15 ++++++--------- sickbeard/metadata/mede8er.py | 3 +-- sickbeard/metadata/mediabrowser.py | 11 +++++++---- sickbeard/metadata/wdtv.py | 10 ++++++---- sickbeard/webserve.py | 7 ++++--- 7 files changed, 36 insertions(+), 32 deletions(-) diff --git a/gui/slick/js/configBackupRestore.js b/gui/slick/js/configBackupRestore.js index 113f5586..3881924b 100644 --- a/gui/slick/js/configBackupRestore.js +++ b/gui/slick/js/configBackupRestore.js @@ -5,7 +5,7 @@ $(document).ready(function(){ $("#Backup").attr("disabled", true); $('#Backup-result').html(loading); var backupDir = $("#backupDir").val(); - $.get(sbRoot + "/config/backup", {'backupDir': backupDir}) + $.get(sbRoot + "/config/backup/", {'backupDir': backupDir}) .done(function (data) { $('#Backup-result').html(data); $("#Backup").attr("disabled", false); @@ -15,7 +15,7 @@ $(document).ready(function(){ $("#Restore").attr("disabled", true); $('#Restore-result').html(loading); var backupFile = $("#backupFile").val(); - $.get(sbRoot + "/config/restore", {'backupFile': backupFile}) + $.get(sbRoot + "/config/restore/", {'backupFile': backupFile}) .done(function (data) { $('#Restore-result').html(data); $("#Restore").attr("disabled", false); diff --git a/lib/tvdb_api/tvdb_api.py b/lib/tvdb_api/tvdb_api.py index e75ed872..638808bb 100644 --- a/lib/tvdb_api/tvdb_api.py +++ b/lib/tvdb_api/tvdb_api.py @@ -797,18 +797,20 @@ class Tvdb: return cur_actors = Actors() - for curActorItem in actorsEt["actor"].items(): + for cur_actor in actorsEt['actor']: curActor = Actor() - for k, v in curActorItem: + for k, v in cur_actor.items(): + if k is None or v is None: + continue + k = k.lower() - if v is not None: - if k == "image": - v = self.config['url_artworkPrefix'] % (v) - else: - v = self._cleanData(v) + if k == "image": + v = self.config['url_artworkPrefix'] % (v) + else: + v = self._cleanData(v) + curActor[k] = v cur_actors.append(curActor) - self._setShowData(sid, '_actors', cur_actors) def _getShowData(self, sid, language, getEpInfo=False): diff --git a/sickbeard/metadata/kodi_12plus.py b/sickbeard/metadata/kodi_12plus.py index 17fd0e0c..9a916b6d 100644 --- a/sickbeard/metadata/kodi_12plus.py +++ b/sickbeard/metadata/kodi_12plus.py @@ -189,19 +189,16 @@ class KODI_12PlusMetadata(generic.GenericMetadata): cur_actor = etree.SubElement(tv_node, "actor") cur_actor_name = etree.SubElement(cur_actor, "name") - cur_actor_name_text = actor['name'] - if isinstance(cur_actor_name_text, basestring): - cur_actor_name.text = cur_actor_name_text.strip() + if getattr(actor, 'name', None) is not None: + cur_actor_name.text = actor['name'].strip() cur_actor_role = etree.SubElement(cur_actor, "role") - cur_actor_role_text = actor['role'] - if cur_actor_role_text != None: - cur_actor_role.text = cur_actor_role_text + if getattr(actor, 'role', None) is not None: + cur_actor_role.text = actor['role'] cur_actor_thumb = etree.SubElement(cur_actor, "thumb") - cur_actor_thumb_text = actor['image'] - if cur_actor_thumb_text != None: - cur_actor_thumb.text = cur_actor_thumb_text + if getattr(actor, 'image', None) is not None: + cur_actor_thumb.text = actor['image'] # Make it purdy helpers.indentXML(tv_node) diff --git a/sickbeard/metadata/mede8er.py b/sickbeard/metadata/mede8er.py index e90bca7e..9e3d836e 100644 --- a/sickbeard/metadata/mede8er.py +++ b/sickbeard/metadata/mede8er.py @@ -199,8 +199,7 @@ class Mede8erMetadata(mediabrowser.MediaBrowserMetadata): if getattr(myShow, '_actors', None) is not None: for actor in myShow['_actors']: - cur_actor_name_text = actor['name'] - + cur_actor_name_text = getattr(actor, 'name', None) if cur_actor_name_text != None and cur_actor_name_text.strip(): cur_actor = etree.SubElement(cast, "actor") cur_actor.text = cur_actor_name_text.strip() diff --git a/sickbeard/metadata/mediabrowser.py b/sickbeard/metadata/mediabrowser.py index ef626f92..b35c076f 100644 --- a/sickbeard/metadata/mediabrowser.py +++ b/sickbeard/metadata/mediabrowser.py @@ -362,14 +362,17 @@ class MediaBrowserMetadata(generic.GenericMetadata): if getattr(myShow, 'actors', None) is not None: for actor in myShow['_actors']: cur_actor = etree.SubElement(Persons, "Person") + cur_actor_name = etree.SubElement(cur_actor, "Name") - cur_actor_name.text = actor['name'].strip() + if getattr(actor, 'name', None): + cur_actor_name.text = actor['name'].strip() + cur_actor_type = etree.SubElement(cur_actor, "Type") cur_actor_type.text = "Actor" + cur_actor_role = etree.SubElement(cur_actor, "Role") - cur_actor_role_text = actor['role'] - if cur_actor_role_text != None: - cur_actor_role.text = cur_actor_role_text + if getattr(actor, 'role', None): + cur_actor_role.text = actor['role'] helpers.indentXML(tv_node) diff --git a/sickbeard/metadata/wdtv.py b/sickbeard/metadata/wdtv.py index f6025796..fe4ed63b 100644 --- a/sickbeard/metadata/wdtv.py +++ b/sickbeard/metadata/wdtv.py @@ -275,12 +275,14 @@ class WDTVMetadata(generic.GenericMetadata): if getattr(myShow, '_actors', None) is not None: for actor in myShow['_actors']: cur_actor = etree.SubElement(episode, "actor") + cur_actor_name = etree.SubElement(cur_actor, "name") - cur_actor_name.text = actor['name'] + if getattr(actor, 'name', None): + cur_actor_name.text = actor['name'] + cur_actor_role = etree.SubElement(cur_actor, "role") - cur_actor_role_text = actor['role'] - if cur_actor_role_text != None: - cur_actor_role.text = cur_actor_role_text + if getattr(actor, 'role', None): + cur_actor_role.text = actor['role'] overview = etree.SubElement(episode, "overview") if curEpToWrite.description != None: diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 895e1534..9643ecc8 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -24,6 +24,7 @@ import time import urllib import re import datetime +import urlparse import sickbeard from sickbeard import config, sab @@ -371,7 +372,7 @@ class WebRoot(WebHandler): default_image_name = 'banner.png' #image_path = ek.ek(os.path.join, sickbeard.PROG_DIR, 'gui', 'slick', 'images', default_image_name) - static_image_path = '/images/' + default_image_name + static_image_path = os.path.join('/images', default_image_name) if show and sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)): cache_obj = image_cache.ImageCache() @@ -386,9 +387,9 @@ class WebRoot(WebHandler): image_file_name = cache_obj.banner_thumb_path(show) if ek.ek(os.path.isfile, image_file_name): - image_path = image_file_name - static_image_path = '/cache' + image_path.replace(sickbeard.CACHE_DIR, '') + static_image_path = os.path.normpath(image_file_name.replace(sickbeard.CACHE_DIR, '/cache')) + static_image_path = static_image_path.replace('\\', '/') return self.redirect(static_image_path) def setHomeLayout(self, layout):