1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Fixes for issue #1026 - Trakt exceptions

This commit is contained in:
echel0n 2014-12-05 22:51:24 -08:00
parent f814de4c82
commit 0365cc201b
4 changed files with 18 additions and 20 deletions

View File

@ -32,11 +32,11 @@ class TraktAPI():
resp = resp.json()
except (requests.HTTPError, requests.ConnectionError) as e:
if e.response.status_code == 401:
raise traktAuthException(e.message)
raise traktAuthException(e)
elif e.response.status_code == 503:
raise traktServerBusy(e.message)
raise traktServerBusy(e)
else:
raise traktException(e.message)
raise traktException(e)
# check and confirm trakt call did not fail
if isinstance(resp, dict) and resp.get('status', False) == 'failure':

View File

@ -18,7 +18,7 @@
import sickbeard
from sickbeard import logger
from sickbeard.exceptions import ex
from lib.trakt import TraktAPI
from lib.trakt.exceptions import traktException, traktServerBusy, traktAuthException
@ -107,7 +107,7 @@ class TraktNotifier:
trakt_api.traktRequest("show/episode/unwatchlist/%APIKEY%", data_show)
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % e.message, logger.WARNING)
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
def test_notify(self, api, username, password):
"""
@ -127,6 +127,6 @@ class TraktNotifier:
if trakt_api.validateAccount():
return True
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % e.message, logger.WARNING)
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
notifier = TraktNotifier

View File

@ -22,6 +22,7 @@ import datetime
import sickbeard
from sickbeard import encodingKludge as ek
from sickbeard.exceptions import ex
from sickbeard import logger
from sickbeard import helpers
from sickbeard import search_queue
@ -70,7 +71,7 @@ class TraktChecker():
traktShow = filter(lambda x: int(indexerid) in [int(x['tvdb_id']) or 0, int(x['tvrage_id'])] or 0, library)
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % e.message, logger.WARNING)
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
return traktShow
@ -81,21 +82,18 @@ class TraktChecker():
self.addShowToTraktLibrary(myShow)
def removeShowFromTraktLibrary(self, show_obj):
data = {}
if self.findShow(show_obj.indexer, show_obj.indexerid):
# URL parameters
data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1]
data['title'] = show_obj.name
data['year'] = show_obj.startyear
data = {'tvdb_id': helpers.mapIndexersToShow(show_obj)[1], 'title': show_obj.name,
'year': show_obj.startyear}
if len(data):
logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG)
try:
self.trakt_api.traktRequest("show/unlibrary/%APIKEY%", data)
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % e.message, logger.WARNING)
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
pass
def addShowToTraktLibrary(self, show_obj):
"""
@ -118,7 +116,7 @@ class TraktChecker():
try:
self.trakt_api.traktRequest("show/library/%APIKEY%", data)
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % e.message, logger.WARNING)
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
return
def updateShows(self):
@ -127,7 +125,7 @@ class TraktChecker():
try:
watchlist = self.trakt_api.traktRequest("user/watchlist/shows.json/%APIKEY%/%USER%")
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % e.message, logger.WARNING)
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
return
if not len(watchlist):
@ -162,7 +160,7 @@ class TraktChecker():
try:
watchlist = self.trakt_api.traktRequest("user/watchlist/episodes.json/%APIKEY%/%USER%")
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % e.message, logger.WARNING)
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
return
if not len(watchlist):

View File

@ -2994,7 +2994,7 @@ class NewHomeAddShows(MainHandler):
for show in recommendedlist if not helpers.findCertainShow(sickbeard.showList, [
int(show[indexers[sickbeard.TRAKT_DEFAULT_INDEXER - 1]])])))
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % e.message, logger.WARNING)
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
return json.dumps({'results': final_results})
@ -3038,7 +3038,7 @@ class NewHomeAddShows(MainHandler):
except exceptions.MultipleShowObjectsException:
continue
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % e.message, logger.WARNING)
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
return _munge(t)