Browse Source

Add Newznab providers can use API only or API + RSS cache fallback. Tip added to Newznab config/Media Providers/API key.

If i=<num>&r=<num> is used as an API key setting, an API call is tried first, then a RSS fallback call if the API returns no cache results.

Add correct user entry mistakes for nzbs2go api url.
tags/release_0.23.13^2
JackDandy 4 years ago
parent
commit
368235fe4e
  1. 8
      CHANGES.md
  2. 7
      gui/slick/interfaces/default/config_providers.tmpl
  3. 28
      sickbeard/providers/newznab.py
  4. 5
      sickbeard/webserve.py

8
CHANGES.md

@ -1,4 +1,10 @@
### 0.23.12 (2021-02-19 17:00:00 UTC)
### 0.23.13 (2021-02-26 19:05:00 UTC)
* Add Newznab providers can use API only or API + RSS cache fallback. Tip added to Newznab config/Media Providers/API key
* Add correct user entry mistakes for nzbs2go api url
### 0.23.12 (2021-02-19 17:00:00 UTC)
* Change allow Python 3.8.8 and 3.9.2

7
gui/slick/interfaces/default/config_providers.tmpl

@ -250,7 +250,7 @@
<span class="component-title">API key</span>
<span class="component-desc">
<input type="text" id="${cur_newznab_provider.get_id()}_hash" value="<%= starify(cur_newznab_provider.key) %>" newznab_name="${cur_newznab_provider.get_id()}_hash" class="newznab_key form-control input-sm input350" />
<div class="clear-left"><p>get API key from provider website</p></div>
<div class="clear-left"><p><code>apikey</code> for API only or <code>i=num&r=key</code> for API + RSS cache fallback</p></div>
</span>
</label>
</div>
@ -835,7 +835,10 @@ name = '' if not client else get_client_instance(sickbeard.TORRENT_METHOD)().nam
<input type="text" id="newznab_key" class="form-control input-sm input350" />
</span>
<span class="component-desc">
<div class="clear-left"><p>note: enter 0 (zero) if not required</p></div>
<div class="clear-left">
<p><code>apikey</code> for API only or <code>i=num&r=key</code> for API + RSS cache fallback<br>
enter 0 (zero) if not required</p>
</div>
</span>
</label>
</div>

28
sickbeard/providers/newznab.py

@ -870,13 +870,35 @@ class NewznabProvider(generic.NZBProvider):
'attrs': ','.join([k for k, v in iteritems(NewznabConstants.providerToIndexerMapping)
if v in self.caps]),
'offset': 0}
use_rss = self.get_id() in ('ninjacentral', )
base_params_rss = {'num': self.limits, 'dl': '1', 'i': '19'}
base_params_rss = {'num': self.limits, 'dl': '1'}
rss_fallback = False
if isinstance(api_key, string_types) and api_key not in ('0', ''):
base_params['apikey'] = api_key
base_params_rss['r'] = api_key
args = re.findall(r'.*?([ir])\s*=\s*([^\s&;]*)', api_key)
if 1 <= len(args):
for (cur_key, cur_value) in args:
base_params_rss[cur_key] = cur_value
if 'r' == cur_key:
rss_fallback = True
base_params['apikey'] = cur_value
if not rss_fallback:
logger.warning('Invalid API key config for API to RSS fallback,'
' not found: i=num&r=key or i=&r=key or &r=key')
return results, n_spaces
for mode in search_params:
params = dict(needed=needed, max_items=max_items, try_all_searches=try_all_searches,
base_params=base_params, base_params_rss=base_params_rss)
results, n_spaces = self._search_core(search_params, **params)
if not self.should_skip() and not results and rss_fallback and 'Cache' == mode:
results, n_spaces = self._search_core(search_params, use_rss=True, **params)
break
return results, n_spaces
def _search_core(self, search_params, needed=None, max_items=400, try_all_searches=False,
use_rss=False, base_params=None, base_params_rss=None):
results, n_spaces = [], {}
total, cnt, search_url, exit_log = 0, len(results), '', True

5
sickbeard/webserve.py

@ -7689,6 +7689,11 @@ class ConfigProviders(Config):
if starify(cur_key, True):
cur_key = ''
# correct user entry mistakes
test_url = cur_url.lower()
if 'nzbs2go' in test_url and test_url.endswith('.com/') or 'api/v1/api' in test_url:
cur_url = 'https://nzbs2go.com/api/v1/'
new_provider = newznab.NewznabProvider(cur_name, cur_url, key=cur_key)
cur_id = new_provider.get_id()

Loading…
Cancel
Save