mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Merge pull request #845 from JackDandy/feature/ChangeNewznab
Change don't fetch caps for disabled usenet providers.
This commit is contained in:
commit
42c8db0dae
6 changed files with 546 additions and 569 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]
|
||||
|
|
|
@ -677,7 +677,7 @@ name = '' if not client else get_client_instance(sickbeard.TORRENT_METHOD)().nam
|
|||
<span style="font-weight:normal">with.. (u)hd, sd, sport, anime</span>
|
||||
</span>
|
||||
<span class="component-desc">
|
||||
<div id="nn-cats">
|
||||
<div id="nn-cats" class="hide">
|
||||
<div class="pull-left">
|
||||
<select class="pull-left" id="newznab_cap" multiple="multiple" style="min-width:10em;min-height:72px"></select>
|
||||
<input class="btn" type="button" class="newznab_cat_update" id="newznab_cat_update" value=">>" style="position:relative;bottom:-15px">
|
||||
|
@ -691,8 +691,11 @@ name = '' if not client else get_client_instance(sickbeard.TORRENT_METHOD)().nam
|
|||
<div id="nn-nocats" class="hide">
|
||||
<span>No extra categories found</span>
|
||||
</div>
|
||||
<div id="nn-enable-for-cats" class="hide">
|
||||
<span class="grey-text">Enable provider for categories</span>
|
||||
</div>
|
||||
<div id="nn-loadcats" class="hide">
|
||||
<span>Loading categories...</span>
|
||||
<span class="grey-text">Loading categories...</span>
|
||||
</div>
|
||||
</span>
|
||||
</label>
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
<!--
|
||||
var sbRoot = '$sbRoot', anonURL = '$sg_str('ANON_REDIRECT')', themeSpinner = '#echo ('', '-dark')['dark' == $sg_str('THEME_NAME', 'dark')]#',
|
||||
top_image_html = '<img src="$sbRoot/images/top.gif" width="31" height="11" alt="Jump to top" />', topmenu = '$topmenu';
|
||||
\$.SickGear = {Root: '${sbRoot}', PID: '${sbPID}'};
|
||||
\$.SickGear = {Root: '${sbRoot}', PID: '${sbPID}', anonURL: '$sg_str('ANON_REDIRECT')'};
|
||||
//-->
|
||||
</script>
|
||||
<script type="text/javascript" src="$sbRoot/js/lib/jquery.scrolltopcontrol-1.1.js"></script>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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/
|
||||
#
|
||||
|
@ -5121,7 +5121,9 @@ class ConfigProviders(Config):
|
|||
return json.dumps({'success': False, 'error': error})
|
||||
|
||||
if name in [n.name for n in sickbeard.newznabProviderList if n.url == url]:
|
||||
tv_categories = newznab.NewznabProvider.clean_newznab_categories([n for n in sickbeard.newznabProviderList if n.name == name][0].all_cats)
|
||||
provider = [n for n in sickbeard.newznabProviderList if n.name == name][0]
|
||||
tv_categories = newznab.NewznabProvider.clean_newznab_categories(provider.all_cats)
|
||||
state = provider.is_enabled()
|
||||
else:
|
||||
providers = dict(zip([x.get_id() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
|
||||
temp_provider = newznab.NewznabProvider(name, url, key)
|
||||
|
@ -5129,8 +5131,9 @@ class ConfigProviders(Config):
|
|||
temp_provider.key = providers[temp_provider.get_id()].key
|
||||
|
||||
tv_categories = newznab.NewznabProvider.clean_newznab_categories(temp_provider.all_cats)
|
||||
state = False
|
||||
|
||||
return json.dumps({'success': True, 'tv_categories': tv_categories, 'error': ''})
|
||||
return json.dumps({'success': True, 'tv_categories': tv_categories, 'state': state, 'error': ''})
|
||||
|
||||
def deleteNewznabProvider(self, nnid):
|
||||
|
||||
|
@ -5301,11 +5304,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