mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-08 11:03:38 +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)
|
### 0.13.0 (2016-xx-xx xx:xx:xx UTC)
|
||||||
|
|
||||||
|
* Change don't fetch caps for disabled nzb providers
|
||||||
|
|
||||||
|
|
||||||
[develop changelog]
|
[develop changelog]
|
||||||
|
|
|
@ -163,24 +163,26 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
self._last_recent_search = value
|
self._last_recent_search = value
|
||||||
|
|
||||||
def check_cap_update(self):
|
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()
|
self.get_caps()
|
||||||
|
|
||||||
def _get_caps_data(self):
|
def _get_caps_data(self):
|
||||||
xml_caps = None
|
xml_caps = None
|
||||||
if datetime.date.today() - self._caps_need_apikey['date'] > datetime.timedelta(days=30) or \
|
if self.enabled:
|
||||||
not self._caps_need_apikey['need']:
|
if datetime.date.today() - self._caps_need_apikey['date'] > datetime.timedelta(days=30) or \
|
||||||
self._caps_need_apikey['need'] = False
|
not self._caps_need_apikey['need']:
|
||||||
data = self.get_url('%s/api?t=caps' % self.url)
|
self._caps_need_apikey['need'] = False
|
||||||
if data:
|
data = self.get_url('%s/api?t=caps' % self.url)
|
||||||
xml_caps = helpers.parse_xml(data)
|
if data:
|
||||||
if (xml_caps is None or not hasattr(xml_caps, 'tag') or xml_caps.tag == 'error' or xml_caps.tag != 'caps') and \
|
xml_caps = helpers.parse_xml(data)
|
||||||
self.maybe_apikey():
|
if (xml_caps is None or not hasattr(xml_caps, 'tag') or xml_caps.tag == 'error' or xml_caps.tag != 'caps') and \
|
||||||
data = self.get_url('%s/api?t=caps&apikey=%s' % (self.url, self.maybe_apikey()))
|
self.maybe_apikey():
|
||||||
if data:
|
data = self.get_url('%s/api?t=caps&apikey=%s' % (self.url, self.maybe_apikey()))
|
||||||
xml_caps = helpers.parse_xml(data)
|
if data:
|
||||||
if xml_caps and hasattr(xml_caps, 'tag') and xml_caps.tag == 'caps':
|
xml_caps = helpers.parse_xml(data)
|
||||||
self._caps_need_apikey = {'need': True, 'date': datetime.date.today()}
|
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
|
return xml_caps
|
||||||
|
|
||||||
def get_caps(self):
|
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:
|
if not caps and self._caps and not all_cats and self._caps_all_cats and not cats and self._caps_cats:
|
||||||
return
|
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']:
|
if not caps and self.get_id() not in ['sick_beard_index']:
|
||||||
caps[INDEXER_TVDB] = 'tvdbid'
|
caps[INDEXER_TVDB] = 'tvdbid'
|
||||||
|
@ -286,7 +289,7 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
logger.WARNING)
|
logger.WARNING)
|
||||||
else:
|
else:
|
||||||
logger.log('Unknown error given from %s: %s' % (self.name, data.get('description', '')),
|
logger.log('Unknown error given from %s: %s' % (self.name, data.get('description', '')),
|
||||||
logger.ERROR)
|
logger.WARNING)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -636,7 +639,7 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
data = helpers.getURL(search_url)
|
data = helpers.getURL(search_url)
|
||||||
|
|
||||||
if not data:
|
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
|
break
|
||||||
|
|
||||||
# hack this in until it's fixed server side
|
# 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)
|
parsed_xml, n_spaces = self.cache.parse_and_get_ns(data)
|
||||||
items = parsed_xml.findall('channel/item')
|
items = parsed_xml.findall('channel/item')
|
||||||
except (StandardError, Exception):
|
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
|
break
|
||||||
|
|
||||||
if not self.check_auth_from_data(parsed_xml):
|
if not self.check_auth_from_data(parsed_xml):
|
||||||
break
|
break
|
||||||
|
|
||||||
if 'rss' != parsed_xml.tag:
|
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
|
break
|
||||||
|
|
||||||
i and time.sleep(2.1)
|
i and time.sleep(2.1)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
# Author: Nic Wolfe <nic@wolfeden.ca>
|
# Author: Nic Wolfe <nic@wolfeden.ca>
|
||||||
# URL: http://code.google.com/p/sickbeard/
|
# URL: http://code.google.com/p/sickbeard/
|
||||||
#
|
#
|
||||||
|
@ -5301,11 +5301,16 @@ class ConfigProviders(Config):
|
||||||
src_enabled = bool(config.to_int(src_enabled))
|
src_enabled = bool(config.to_int(src_enabled))
|
||||||
|
|
||||||
if '' != getattr(sources[src_name], 'enabled', '') and sources[src_name].is_enabled() != 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
|
sources[src_name].enabled = src_enabled
|
||||||
if not reload_page and sickbeard.GenericProvider.TORRENT == sources[src_name].providerType:
|
if not reload_page and sickbeard.GenericProvider.TORRENT == sources[src_name].providerType:
|
||||||
reload_page = True
|
reload_page = True
|
||||||
|
|
||||||
if src_name in newznab_sources:
|
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
|
newznab_sources[src_name].enabled = src_enabled
|
||||||
elif src_name in torrent_rss_sources:
|
elif src_name in torrent_rss_sources:
|
||||||
torrent_rss_sources[src_name].enabled = src_enabled
|
torrent_rss_sources[src_name].enabled = src_enabled
|
||||||
|
|
Loading…
Reference in a new issue