mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change don't fetch caps for disabled usenet providers.
This commit is contained in:
parent
980bd3fa9b
commit
2b27e3bb74
3 changed files with 29 additions and 20 deletions
|
@ -1,5 +1,6 @@
|
|||
### 0.13.0 (2016-xx-xx xx:xx:xx UTC)
|
||||
|
||||
* Change don't fetch caps for disabled nzb providers
|
||||
|
||||
|
||||
[develop changelog]
|
||||
|
|
|
@ -163,24 +163,26 @@ class NewznabProvider(generic.NZBProvider):
|
|||
self._last_recent_search = value
|
||||
|
||||
def check_cap_update(self):
|
||||
if not self._caps or (datetime.datetime.now() - self._caps_last_updated) >= datetime.timedelta(days=1):
|
||||
if self.enabled and \
|
||||
(not self._caps or (datetime.datetime.now() - self._caps_last_updated) >= datetime.timedelta(days=1)):
|
||||
self.get_caps()
|
||||
|
||||
def _get_caps_data(self):
|
||||
xml_caps = None
|
||||
if datetime.date.today() - self._caps_need_apikey['date'] > datetime.timedelta(days=30) or \
|
||||
not self._caps_need_apikey['need']:
|
||||
self._caps_need_apikey['need'] = False
|
||||
data = self.get_url('%s/api?t=caps' % self.url)
|
||||
if data:
|
||||
xml_caps = helpers.parse_xml(data)
|
||||
if (xml_caps is None or not hasattr(xml_caps, 'tag') or xml_caps.tag == 'error' or xml_caps.tag != 'caps') and \
|
||||
self.maybe_apikey():
|
||||
data = self.get_url('%s/api?t=caps&apikey=%s' % (self.url, self.maybe_apikey()))
|
||||
if data:
|
||||
xml_caps = helpers.parse_xml(data)
|
||||
if xml_caps and hasattr(xml_caps, 'tag') and xml_caps.tag == 'caps':
|
||||
self._caps_need_apikey = {'need': True, 'date': datetime.date.today()}
|
||||
if self.enabled:
|
||||
if datetime.date.today() - self._caps_need_apikey['date'] > datetime.timedelta(days=30) or \
|
||||
not self._caps_need_apikey['need']:
|
||||
self._caps_need_apikey['need'] = False
|
||||
data = self.get_url('%s/api?t=caps' % self.url)
|
||||
if data:
|
||||
xml_caps = helpers.parse_xml(data)
|
||||
if (xml_caps is None or not hasattr(xml_caps, 'tag') or xml_caps.tag == 'error' or xml_caps.tag != 'caps') and \
|
||||
self.maybe_apikey():
|
||||
data = self.get_url('%s/api?t=caps&apikey=%s' % (self.url, self.maybe_apikey()))
|
||||
if data:
|
||||
xml_caps = helpers.parse_xml(data)
|
||||
if xml_caps and hasattr(xml_caps, 'tag') and xml_caps.tag == 'caps':
|
||||
self._caps_need_apikey = {'need': True, 'date': datetime.date.today()}
|
||||
return xml_caps
|
||||
|
||||
def get_caps(self):
|
||||
|
@ -228,7 +230,8 @@ class NewznabProvider(generic.NZBProvider):
|
|||
if not caps and self._caps and not all_cats and self._caps_all_cats and not cats and self._caps_cats:
|
||||
return
|
||||
|
||||
self._caps_last_updated = datetime.datetime.now()
|
||||
if self.enabled:
|
||||
self._caps_last_updated = datetime.datetime.now()
|
||||
|
||||
if not caps and self.get_id() not in ['sick_beard_index']:
|
||||
caps[INDEXER_TVDB] = 'tvdbid'
|
||||
|
@ -286,7 +289,7 @@ class NewznabProvider(generic.NZBProvider):
|
|||
logger.WARNING)
|
||||
else:
|
||||
logger.log('Unknown error given from %s: %s' % (self.name, data.get('description', '')),
|
||||
logger.ERROR)
|
||||
logger.WARNING)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -636,7 +639,7 @@ class NewznabProvider(generic.NZBProvider):
|
|||
data = helpers.getURL(search_url)
|
||||
|
||||
if not data:
|
||||
logger.log('No Data returned from %s' % self.name, logger.DEBUG)
|
||||
logger.log('No Data returned from %s' % self.name, logger.WARNING)
|
||||
break
|
||||
|
||||
# hack this in until it's fixed server side
|
||||
|
@ -647,14 +650,14 @@ class NewznabProvider(generic.NZBProvider):
|
|||
parsed_xml, n_spaces = self.cache.parse_and_get_ns(data)
|
||||
items = parsed_xml.findall('channel/item')
|
||||
except (StandardError, Exception):
|
||||
logger.log('Error trying to load %s RSS feed' % self.name, logger.ERROR)
|
||||
logger.log('Error trying to load %s RSS feed' % self.name, logger.WARNING)
|
||||
break
|
||||
|
||||
if not self.check_auth_from_data(parsed_xml):
|
||||
break
|
||||
|
||||
if 'rss' != parsed_xml.tag:
|
||||
logger.log('Resulting XML from %s isn\'t RSS, not parsing it' % self.name, logger.ERROR)
|
||||
logger.log('Resulting XML from %s isn\'t RSS, not parsing it' % self.name, logger.WARNING)
|
||||
break
|
||||
|
||||
i and time.sleep(2.1)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# coding=utf-8
|
||||
# coding=utf-8
|
||||
# Author: Nic Wolfe <nic@wolfeden.ca>
|
||||
# URL: http://code.google.com/p/sickbeard/
|
||||
#
|
||||
|
@ -5301,11 +5301,16 @@ class ConfigProviders(Config):
|
|||
src_enabled = bool(config.to_int(src_enabled))
|
||||
|
||||
if '' != getattr(sources[src_name], 'enabled', '') and sources[src_name].is_enabled() != src_enabled:
|
||||
if isinstance(sources[src_name], sickbeard.providers.newznab.NewznabProvider) and \
|
||||
not sources[src_name].enabled and src_enabled:
|
||||
reload_page = True
|
||||
sources[src_name].enabled = src_enabled
|
||||
if not reload_page and sickbeard.GenericProvider.TORRENT == sources[src_name].providerType:
|
||||
reload_page = True
|
||||
|
||||
if src_name in newznab_sources:
|
||||
if not newznab_sources[src_name].enabled and src_enabled:
|
||||
reload_page = True
|
||||
newznab_sources[src_name].enabled = src_enabled
|
||||
elif src_name in torrent_rss_sources:
|
||||
torrent_rss_sources[src_name].enabled = src_enabled
|
||||
|
|
Loading…
Reference in a new issue