Fix for newznab provider searches

This commit is contained in:
echel0n 2014-08-22 23:22:46 -07:00
parent dbb3b75d6e
commit f65262e0e9

View file

@ -208,22 +208,18 @@ class NewznabProvider(generic.NZBProvider):
results = [] results = []
keep_searching = 1 keep_searching = 1
while keep_searching: while True:
search_url = self.url + 'api?' + urllib.urlencode(params) search_url = self.url + 'api?' + urllib.urlencode(params)
logger.log(u"Search url: " + search_url, logger.DEBUG) logger.log(u"Search url: " + search_url, logger.DEBUG)
data = self.cache.getRSSFeed(search_url) data = self.cache.getRSSFeed(search_url)
if not data:
keep_searching = 0
if self._checkAuthFromData(data): if data and self._checkAuthFromData(data):
for item in data:
items = data.entries (title, url) = self._get_title_and_url(item)
for curItem in items:
(title, url) = self._get_title_and_url(curItem)
if title and url: if title and url:
results.append(curItem) results.append(item)
else: else:
logger.log( logger.log(
u"The data returned from the " + self.name + " is incomplete, this result is unusable", u"The data returned from the " + self.name + " is incomplete, this result is unusable",
@ -234,20 +230,20 @@ class NewznabProvider(generic.NZBProvider):
total = int(data.feed.newznab_response['total']) total = int(data.feed.newznab_response['total'])
offset = int(data.feed.newznab_response['offset']) offset = int(data.feed.newznab_response['offset'])
except (AttributeError, TypeError): except (AttributeError, TypeError):
keep_searching = 0 break
# if there are more items available then the amount given in one call, grab some more # if there are more items available then the amount given in one call, grab some more
if (total - params['limit']) > offset == params['offset']: if (total - params['limit']) > offset == params['offset']:
params['offset'] += params['limit'] params['offset'] += params['limit']
logger.log(str(total - params['offset']) + " more items to be fetched from provider. Fetching another " + str(params['limit']) + " items.", logger.DEBUG) logger.log(str(total - params['offset']) + " more items to be fetched from provider. Fetching another " + str(params['limit']) + " items.", logger.DEBUG)
else: else:
keep_searching = 0 break
# sanity check - limiting at 10 at getting 1000 results in-case incorrect total parameter is reported # sanity check - limiting at 10 at getting 1000 results in-case incorrect total parameter is reported
if params['limit'] > 1000: if params['limit'] > 1000:
keep_searching = 0 break
else: else:
keep_searching = 0 break
return results return results