mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-22 01:23:43 +00:00
Change how starified keys are handled with newznab categories.
Add more logging to newznab modes.
This commit is contained in:
parent
579d9b4366
commit
1811f7176e
2 changed files with 32 additions and 26 deletions
|
@ -224,7 +224,7 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
base_params['apikey'] = api_key
|
base_params['apikey'] = api_key
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
total = 0
|
total, cnt, search_url, exit_log = 0, len(results), '', False
|
||||||
|
|
||||||
for mode in search_params.keys():
|
for mode in search_params.keys():
|
||||||
for i, params in enumerate(search_params[mode]):
|
for i, params in enumerate(search_params[mode]):
|
||||||
|
@ -285,8 +285,13 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
break
|
break
|
||||||
|
|
||||||
# No items found or cache mode, prevent from doing another search
|
# No items found, prevent from doing another search
|
||||||
if 0 == total or 'Cache' == mode:
|
if 0 == total:
|
||||||
|
break
|
||||||
|
|
||||||
|
# Cache mode, prevent from doing another search
|
||||||
|
if 'Cache' == mode:
|
||||||
|
exit_log = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if offset != request_params['offset']:
|
if offset != request_params['offset']:
|
||||||
|
@ -295,6 +300,7 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
|
|
||||||
request_params['offset'] += request_params['limit']
|
request_params['offset'] += request_params['limit']
|
||||||
if total <= request_params['offset']:
|
if total <= request_params['offset']:
|
||||||
|
exit_log = True
|
||||||
logger.log('%s item%s found that will be used for episode matching' % (total, helpers.maybe_plural(total)),
|
logger.log('%s item%s found that will be used for episode matching' % (total, helpers.maybe_plural(total)),
|
||||||
logger.DEBUG)
|
logger.DEBUG)
|
||||||
break
|
break
|
||||||
|
@ -304,15 +310,23 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
logger.log('%s more item%s to fetch from a batch of up to %s items.'
|
logger.log('%s more item%s to fetch from a batch of up to %s items.'
|
||||||
% (items, helpers.maybe_plural(items), request_params['limit']), logger.DEBUG)
|
% (items, helpers.maybe_plural(items), request_params['limit']), logger.DEBUG)
|
||||||
|
|
||||||
batch_count = len(results) - cnt
|
batch_count = self._log_result(results, mode, cnt, search_url)
|
||||||
if batch_count:
|
|
||||||
self._log_search(mode, batch_count, search_url)
|
if exit_log:
|
||||||
|
self._log_result(results, mode, cnt, search_url)
|
||||||
|
exit_log = False
|
||||||
|
|
||||||
if 'tvdbid' in request_params and len(results):
|
if 'tvdbid' in request_params and len(results):
|
||||||
break
|
break
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
def _log_result(self, results, mode, cnt, url):
|
||||||
|
count = len(results) - cnt
|
||||||
|
if count:
|
||||||
|
self._log_search(mode, count, url)
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
class NewznabCache(tvcache.TVCache):
|
class NewznabCache(tvcache.TVCache):
|
||||||
|
|
||||||
|
|
|
@ -4240,33 +4240,25 @@ class ConfigProviders(Config):
|
||||||
return newProvider.get_id() + '|' + newProvider.config_str()
|
return newProvider.get_id() + '|' + newProvider.config_str()
|
||||||
|
|
||||||
def getNewznabCategories(self, name, url, key):
|
def getNewznabCategories(self, name, url, key):
|
||||||
'''
|
"""
|
||||||
Retrieves a list of possible categories with category id's
|
Retrieves a list of possible categories with category id's
|
||||||
Using the default url/api?cat
|
Using the default url/api?cat
|
||||||
http://yournewznaburl.com/api?t=caps&apikey=yourapikey
|
http://yournewznaburl.com/api?t=caps&apikey=yourapikey
|
||||||
'''
|
"""
|
||||||
error = ''
|
|
||||||
success = False
|
|
||||||
|
|
||||||
if not name:
|
error = not name and 'Name' or not url and 'Url' or not key and 'Apikey' or ''
|
||||||
error += '\nNo Provider Name specified'
|
if error:
|
||||||
if not url:
|
error = '\nNo provider %s specified' % error
|
||||||
error += '\nNo Provider Url specified'
|
return json.dumps({'success': False, 'error': error})
|
||||||
if not key:
|
|
||||||
error += '\nNo Provider Api key specified'
|
|
||||||
|
|
||||||
if error <> '':
|
providers = dict(zip([x.get_id() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
|
||||||
return json.dumps({'success' : False, 'error': error})
|
temp_provider = newznab.NewznabProvider(name, url, key)
|
||||||
|
if None is not key and starify(key, True):
|
||||||
|
temp_provider.key = providers[temp_provider.get_id()].key
|
||||||
|
|
||||||
#Get list with Newznabproviders
|
success, tv_categories, error = temp_provider.get_newznab_categories()
|
||||||
#providerDict = dict(zip([x.get_id() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
|
|
||||||
|
|
||||||
#Get newznabprovider obj with provided name
|
return json.dumps({'success': success, 'tv_categories': tv_categories, 'error': error})
|
||||||
tempProvider= newznab.NewznabProvider(name, url, key)
|
|
||||||
|
|
||||||
success, tv_categories, error = tempProvider.get_newznab_categories()
|
|
||||||
|
|
||||||
return json.dumps({'success' : success,'tv_categories' : tv_categories, 'error' : error})
|
|
||||||
|
|
||||||
def deleteNewznabProvider(self, nnid):
|
def deleteNewznabProvider(self, nnid):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue