From e53a9ed30a17b82f0a28475c9372f78238208867 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 15 Nov 2012 18:30:45 +0100 Subject: [PATCH] Try next on failed download from provider --- couchpotato/core/plugins/searcher/main.py | 2 +- couchpotato/core/providers/base.py | 8 +++++++- couchpotato/core/providers/nzb/newzbin/main.py | 3 ++- couchpotato/core/providers/nzb/newznab/main.py | 3 ++- couchpotato/core/providers/nzb/nzbmatrix/main.py | 3 --- couchpotato/core/providers/nzb/nzbsrus/main.py | 3 --- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/couchpotato/core/plugins/searcher/main.py b/couchpotato/core/plugins/searcher/main.py index 312d2388..55115122 100644 --- a/couchpotato/core/plugins/searcher/main.py +++ b/couchpotato/core/plugins/searcher/main.py @@ -239,7 +239,7 @@ class Searcher(Plugin): filedata = None if data.get('download') and (ismethod(data.get('download')) or isfunction(data.get('download'))): filedata = data.get('download')(url = data.get('url'), nzb_id = data.get('id')) - if filedata is 'try_next': + if filedata == 'try_next': return filedata successful = fireEvent('download', data = data, movie = movie, manual = manual, filedata = filedata, single = True) diff --git a/couchpotato/core/providers/base.py b/couchpotato/core/providers/base.py index 17ccb2a5..50a659b0 100644 --- a/couchpotato/core/providers/base.py +++ b/couchpotato/core/providers/base.py @@ -6,6 +6,7 @@ from couchpotato.environment import Env from urlparse import urlparse import re import time +import traceback log = CPLog(__name__) @@ -56,7 +57,12 @@ class YarrProvider(Provider): addEvent('nzb.feed', self.feed) def download(self, url = '', nzb_id = ''): - return self.urlopen(url) + try: + return self.urlopen(url, headers = {'User-Agent': Env.getIdentifier()}, show_error = False) + except: + log.error('Failed getting nzb from %s: %s', (self.getName(), traceback.format_exc())) + + return 'try_next' def feed(self): return [] diff --git a/couchpotato/core/providers/nzb/newzbin/main.py b/couchpotato/core/providers/nzb/newzbin/main.py index 55019ad5..7359bfdc 100644 --- a/couchpotato/core/providers/nzb/newzbin/main.py +++ b/couchpotato/core/providers/nzb/newzbin/main.py @@ -144,7 +144,8 @@ class Newzbin(NZBProvider, RSS): }, show_error = False) except Exception, e: log.error('Failed downloading from newzbin, check credit: %s', e) - return False + + return 'try_next' def getFormatId(self, format): for id, quality in self.format_ids.iteritems(): diff --git a/couchpotato/core/providers/nzb/newznab/main.py b/couchpotato/core/providers/nzb/newznab/main.py index 2ea36a3b..43ea2bd0 100644 --- a/couchpotato/core/providers/nzb/newznab/main.py +++ b/couchpotato/core/providers/nzb/newznab/main.py @@ -219,4 +219,5 @@ class Newznab(NZBProvider, RSS): return 'try_next' log.error('Failed download from %s', (host, traceback.format_exc())) - raise + + return 'try_next' diff --git a/couchpotato/core/providers/nzb/nzbmatrix/main.py b/couchpotato/core/providers/nzb/nzbmatrix/main.py index 9539eac1..4da2fbd9 100644 --- a/couchpotato/core/providers/nzb/nzbmatrix/main.py +++ b/couchpotato/core/providers/nzb/nzbmatrix/main.py @@ -98,9 +98,6 @@ class NZBMatrix(NZBProvider, RSS): return results - def download(self, url = '', nzb_id = ''): - return self.urlopen(url, headers = {'User-Agent': Env.getIdentifier()}) - def getApiExt(self): return '&username=%s&apikey=%s' % (self.conf('username'), self.conf('api_key')) diff --git a/couchpotato/core/providers/nzb/nzbsrus/main.py b/couchpotato/core/providers/nzb/nzbsrus/main.py index 20a51d56..b92d6774 100644 --- a/couchpotato/core/providers/nzb/nzbsrus/main.py +++ b/couchpotato/core/providers/nzb/nzbsrus/main.py @@ -97,8 +97,5 @@ class Nzbsrus(NZBProvider, RSS): return results - def download(self, url = '', nzb_id = ''): - return self.urlopen(url, headers = {'User-Agent': Env.getIdentifier()}) - def getApiExt(self): return '/%s/' % (self.conf('userid'))