mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-07 03:48:02 -05:00
Fixes for issue #1026 - Trakt exceptions
This commit is contained in:
parent
f814de4c82
commit
0365cc201b
@ -32,11 +32,11 @@ class TraktAPI():
|
|||||||
resp = resp.json()
|
resp = resp.json()
|
||||||
except (requests.HTTPError, requests.ConnectionError) as e:
|
except (requests.HTTPError, requests.ConnectionError) as e:
|
||||||
if e.response.status_code == 401:
|
if e.response.status_code == 401:
|
||||||
raise traktAuthException(e.message)
|
raise traktAuthException(e)
|
||||||
elif e.response.status_code == 503:
|
elif e.response.status_code == 503:
|
||||||
raise traktServerBusy(e.message)
|
raise traktServerBusy(e)
|
||||||
else:
|
else:
|
||||||
raise traktException(e.message)
|
raise traktException(e)
|
||||||
|
|
||||||
# check and confirm trakt call did not fail
|
# check and confirm trakt call did not fail
|
||||||
if isinstance(resp, dict) and resp.get('status', False) == 'failure':
|
if isinstance(resp, dict) and resp.get('status', False) == 'failure':
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
from sickbeard import logger
|
from sickbeard import logger
|
||||||
|
from sickbeard.exceptions import ex
|
||||||
from lib.trakt import TraktAPI
|
from lib.trakt import TraktAPI
|
||||||
from lib.trakt.exceptions import traktException, traktServerBusy, traktAuthException
|
from lib.trakt.exceptions import traktException, traktServerBusy, traktAuthException
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class TraktNotifier:
|
|||||||
|
|
||||||
trakt_api.traktRequest("show/episode/unwatchlist/%APIKEY%", data_show)
|
trakt_api.traktRequest("show/episode/unwatchlist/%APIKEY%", data_show)
|
||||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
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):
|
def test_notify(self, api, username, password):
|
||||||
"""
|
"""
|
||||||
@ -127,6 +127,6 @@ class TraktNotifier:
|
|||||||
if trakt_api.validateAccount():
|
if trakt_api.validateAccount():
|
||||||
return True
|
return True
|
||||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
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
|
notifier = TraktNotifier
|
||||||
|
@ -22,6 +22,7 @@ import datetime
|
|||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
from sickbeard import encodingKludge as ek
|
from sickbeard import encodingKludge as ek
|
||||||
|
from sickbeard.exceptions import ex
|
||||||
from sickbeard import logger
|
from sickbeard import logger
|
||||||
from sickbeard import helpers
|
from sickbeard import helpers
|
||||||
from sickbeard import search_queue
|
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)
|
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:
|
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
|
return traktShow
|
||||||
|
|
||||||
@ -81,21 +82,18 @@ class TraktChecker():
|
|||||||
self.addShowToTraktLibrary(myShow)
|
self.addShowToTraktLibrary(myShow)
|
||||||
|
|
||||||
def removeShowFromTraktLibrary(self, show_obj):
|
def removeShowFromTraktLibrary(self, show_obj):
|
||||||
data = {}
|
|
||||||
|
|
||||||
if self.findShow(show_obj.indexer, show_obj.indexerid):
|
if self.findShow(show_obj.indexer, show_obj.indexerid):
|
||||||
# URL parameters
|
# URL parameters
|
||||||
data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1]
|
data = {'tvdb_id': helpers.mapIndexersToShow(show_obj)[1], 'title': show_obj.name,
|
||||||
data['title'] = show_obj.name
|
'year': show_obj.startyear}
|
||||||
data['year'] = show_obj.startyear
|
|
||||||
|
|
||||||
if len(data):
|
|
||||||
logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG)
|
logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.trakt_api.traktRequest("show/unlibrary/%APIKEY%", data)
|
self.trakt_api.traktRequest("show/unlibrary/%APIKEY%", data)
|
||||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
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):
|
def addShowToTraktLibrary(self, show_obj):
|
||||||
"""
|
"""
|
||||||
@ -118,7 +116,7 @@ class TraktChecker():
|
|||||||
try:
|
try:
|
||||||
self.trakt_api.traktRequest("show/library/%APIKEY%", data)
|
self.trakt_api.traktRequest("show/library/%APIKEY%", data)
|
||||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
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
|
return
|
||||||
|
|
||||||
def updateShows(self):
|
def updateShows(self):
|
||||||
@ -127,7 +125,7 @@ class TraktChecker():
|
|||||||
try:
|
try:
|
||||||
watchlist = self.trakt_api.traktRequest("user/watchlist/shows.json/%APIKEY%/%USER%")
|
watchlist = self.trakt_api.traktRequest("user/watchlist/shows.json/%APIKEY%/%USER%")
|
||||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
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
|
return
|
||||||
|
|
||||||
if not len(watchlist):
|
if not len(watchlist):
|
||||||
@ -162,7 +160,7 @@ class TraktChecker():
|
|||||||
try:
|
try:
|
||||||
watchlist = self.trakt_api.traktRequest("user/watchlist/episodes.json/%APIKEY%/%USER%")
|
watchlist = self.trakt_api.traktRequest("user/watchlist/episodes.json/%APIKEY%/%USER%")
|
||||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
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
|
return
|
||||||
|
|
||||||
if not len(watchlist):
|
if not len(watchlist):
|
||||||
|
@ -2994,7 +2994,7 @@ class NewHomeAddShows(MainHandler):
|
|||||||
for show in recommendedlist if not helpers.findCertainShow(sickbeard.showList, [
|
for show in recommendedlist if not helpers.findCertainShow(sickbeard.showList, [
|
||||||
int(show[indexers[sickbeard.TRAKT_DEFAULT_INDEXER - 1]])])))
|
int(show[indexers[sickbeard.TRAKT_DEFAULT_INDEXER - 1]])])))
|
||||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
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})
|
return json.dumps({'results': final_results})
|
||||||
|
|
||||||
@ -3038,7 +3038,7 @@ class NewHomeAddShows(MainHandler):
|
|||||||
except exceptions.MultipleShowObjectsException:
|
except exceptions.MultipleShowObjectsException:
|
||||||
continue
|
continue
|
||||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
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)
|
return _munge(t)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user