From aba9d57439b300c662de307bcee00f0564d55bee Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 12 Jun 2012 20:11:16 +0200 Subject: [PATCH] Catch trakt errors --- .../core/providers/automation/trakt/main.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/couchpotato/core/providers/automation/trakt/main.py b/couchpotato/core/providers/automation/trakt/main.py index 0c1ada86..764f6cfc 100644 --- a/couchpotato/core/providers/automation/trakt/main.py +++ b/couchpotato/core/providers/automation/trakt/main.py @@ -41,13 +41,19 @@ class Trakt(Automation): def call(self, method_url): - if self.conf('automation_password'): - headers = { - 'Authorization': 'Basic %s' % base64.encodestring('%s:%s' % (self.conf('automation_username'), self.conf('automation_password')))[:-1] - } - else: - headers = {} + try: + if self.conf('automation_password'): + headers = { + 'Authorization': 'Basic %s' % base64.encodestring('%s:%s' % (self.conf('automation_username'), self.conf('automation_password')))[:-1] + } + else: + headers = {} - cache_key = 'trakt.%s' % md5(method_url) - json_string = self.getCache(cache_key, self.urls['base'] + method_url, headers = headers) - return json.loads(json_string) + cache_key = 'trakt.%s' % md5(method_url) + json_string = self.getCache(cache_key, self.urls['base'] + method_url, headers = headers) + if json_string: + return json.loads(json_string) + except: + log.error('Failed to get data from trakt, check your login.') + + return []