diff --git a/gui/slick/images/providers/spotweb.png b/gui/slick/images/providers/spotweb.png
new file mode 100644
index 00000000..60bf038d
Binary files /dev/null and b/gui/slick/images/providers/spotweb.png differ
diff --git a/gui/slick/interfaces/default/config_providers.tmpl b/gui/slick/interfaces/default/config_providers.tmpl
index 10091857..a70405e1 100644
--- a/gui/slick/interfaces/default/config_providers.tmpl
+++ b/gui/slick/interfaces/default/config_providers.tmpl
@@ -2,6 +2,7 @@
#from sickbeard.clients import get_client_instance
#from sickbeard.providers.generic import GenericProvider
#from sickbeard.providers import thepiratebay
+#from sickbeard.providers.newznab import NewznabConstants
#from sickbeard.helpers import anon_url, starify
##
#set global $title = 'Config - Providers'
@@ -95,6 +96,7 @@
#set $cur_name = $cur_provider.get_id()
#set $cur_url = $cur_provider.url
#set $show_type = $sickbeard.USE_NZBS and $sickbeard.USE_TORRENTS and $GenericProvider.NZB == $cur_provider.providerType
+ #set $spotweb = ('', 'sw ')[$getattr($cur_provider, 'server_type', None) == $NewznabConstants.SERVER_SPOTWEB and type($cur_provider).__name__ not in ['TorrentRssProvider']]
#set $bad_url = not $cur_url and cur_provider.is_enabled()
#set $tip = ($cur_provider.name + ('', ' (enable for link)')[not $cur_url and not cur_provider.is_enabled()],
'Site Down')[$bad_url]
@@ -106,7 +108,7 @@
#if $cur_provider.is_public_access() and type($cur_provider).__name__ not in ['TorrentRssProvider']#
(PA)
#end if##if $show_type##slurp
- ($cur_provider.providerType)
+ ($spotweb$cur_provider.providerType)
#end if##if not $cur_provider.supports_backlog#*#set $backlog_only_tip=True##end if##slurp
diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py
index 9731eb2d..6b299a18 100755
--- a/sickbeard/__init__.py
+++ b/sickbeard/__init__.py
@@ -44,6 +44,7 @@ from sickbeard.common import SD, SKIPPED
from sickbeard.databases import mainDB, cache_db, failed_db
from sickbeard.exceptions import ex
from sickbeard.providers.generic import GenericProvider
+from sickbeard.providers.newznab import NewznabConstants
from sickbeard.watchedstate import EmbyWatchedStateUpdater, PlexWatchedStateUpdater
from indexers.indexer_config import INDEXER_TVDB
from indexers.indexer_api import indexerApi
@@ -1275,7 +1276,7 @@ def initialize(console_logging=True):
('api_key', ''), ('username', ''),
('scene_only', False), ('scene_or_contain', ''), ('scene_loose', False), ('scene_loose_active', False),
('scene_rej_nuked', False), ('scene_nuked_active', False),
- ('search_mode', 'eponly'), ('search_fallback', False)
+ ('search_mode', 'eponly'), ('search_fallback', False), ('server_type', NewznabConstants.SERVER_DEFAULT)
]:
if hasattr(nzb_prov, attr):
attr_check = '%s_%s' % (prov_id, attr.strip('_'))
@@ -1742,7 +1743,7 @@ def save_config():
for attr in [x for x in ['enable_recentsearch', 'enable_backlog', 'enable_scheduled_backlog',
'scene_only', 'scene_loose', 'scene_loose_active',
'scene_rej_nuked', 'scene_nuked_active',
- 'search_fallback']
+ 'search_fallback', 'server_type']
if hasattr(src, x)]:
new_config[src_id_uc]['%s_%s' % (src_id, attr)] = helpers.tryInt(getattr(src, attr, None))
diff --git a/sickbeard/providers/__init__.py b/sickbeard/providers/__init__.py
index 5acbed3a..1b819d9b 100755
--- a/sickbeard/providers/__init__.py
+++ b/sickbeard/providers/__init__.py
@@ -22,6 +22,7 @@ import os.path
import sickbeard
from . import generic
+from .newznab import NewznabConstants
from sickbeard import logger, encodingKludge as ek
# usenet
from . import newznab, omgwtfnzbs
@@ -151,14 +152,10 @@ def getNewznabProviderList(data):
providerList.append(curDefault)
else:
providerDict[curDefault.name].default = True
- providerDict[curDefault.name].name = curDefault.name
- providerDict[curDefault.name].url = curDefault.url
- providerDict[curDefault.name].needs_auth = curDefault.needs_auth
- providerDict[curDefault.name].search_mode = curDefault.search_mode
- providerDict[curDefault.name].search_fallback = curDefault.search_fallback
- providerDict[curDefault.name].enable_recentsearch = curDefault.enable_recentsearch
- providerDict[curDefault.name].enable_backlog = curDefault.enable_backlog
- providerDict[curDefault.name].enable_scheduled_backlog = curDefault.enable_scheduled_backlog
+ for k in ('name', 'url', 'needs_auth', 'search_mode', 'search_fallback',
+ 'enable_recentsearch', 'enable_backlog', 'enable_scheduled_backlog',
+ 'server_type'):
+ setattr(providerDict[curDefault.name], k, getattr(curDefault, k))
return filter(lambda x: x, providerList)
@@ -167,34 +164,24 @@ def makeNewznabProvider(configString):
if not configString:
return None
- search_mode = 'eponly'
- search_fallback = 0
- enable_recentsearch = 0
- enable_backlog = 0
- enable_scheduled_backlog = 1
-
- try:
- values = configString.split('|')
- if len(values) == 10:
- name, url, key, cat_ids, enabled, search_mode, search_fallback, enable_recentsearch, enable_backlog, \
- enable_scheduled_backlog = values
- elif len(values) == 9:
- name, url, key, cat_ids, enabled, search_mode, search_fallback, enable_recentsearch, enable_backlog = values
- else:
- name = values[0]
- url = values[1]
- key = values[2]
- cat_ids = values[3]
- enabled = values[4]
- except ValueError:
- logger.log(u"Skipping Newznab provider string: '" + configString + "', incorrect format", logger.ERROR)
+ values = configString.split('|')
+ if 5 <= len(values):
+ name, url, enabled = values.pop(0), values.pop(0), values.pop(4-2)
+ params = dict()
+ for k, d in (('key', ''), ('cat_ids', ''), ('search_mode', 'eponly'), ('search_fallback', 0),
+ ('enable_recentsearch', 0), ('enable_backlog', 0), ('enable_scheduled_backlog', 1),
+ ('server_type', NewznabConstants.SERVER_DEFAULT)):
+ try:
+ params.update({k: values.pop(0)})
+ except IndexError:
+ params.update({k: d})
+ else:
+ logger.log(u'Skipping Newznab provider string: \'%s\', incorrect format' % configString, logger.ERROR)
return None
newznab = sys.modules['sickbeard.providers.newznab']
- newProvider = newznab.NewznabProvider(name, url, key=key, cat_ids=cat_ids, search_mode=search_mode,
- search_fallback=search_fallback, enable_recentsearch=enable_recentsearch,
- enable_backlog=enable_backlog, enable_scheduled_backlog=enable_scheduled_backlog)
+ newProvider = newznab.NewznabProvider(name, url, **params)
newProvider.enabled = enabled == '1'
return newProvider
diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py
index c02483f9..307e6906 100755
--- a/sickbeard/providers/newznab.py
+++ b/sickbeard/providers/newznab.py
@@ -92,6 +92,12 @@ class NewznabConstants:
'season': SEARCH_SEASON,
'ep': SEARCH_EPISODE}
+ SERVER_DEFAULT = 0
+ SERVER_SPOTWEB = 1
+
+ server_types = {SERVER_DEFAULT: 'newznab',
+ SERVER_SPOTWEB: 'spotweb'}
+
def __init__(self):
pass
@@ -99,11 +105,12 @@ class NewznabConstants:
class NewznabProvider(generic.NZBProvider):
def __init__(self, name, url, key='', cat_ids=None, search_mode=None, search_fallback=False,
- enable_recentsearch=False, enable_backlog=False, enable_scheduled_backlog=False):
+ enable_recentsearch=False, enable_backlog=False, enable_scheduled_backlog=False, server_type=None):
generic.NZBProvider.__init__(self, name, True, False)
self.url = url
self.key = key
+ self.server_type = tryInt(server_type, None) or NewznabConstants.SERVER_DEFAULT
self._exclude = set()
self.cat_ids = cat_ids or ''
self._cat_ids = None
@@ -185,6 +192,11 @@ class NewznabProvider(generic.NZBProvider):
pass
self._last_recent_search = value
+ def image_name(self):
+
+ return generic.GenericProvider.image_name(
+ self, ('newznab', 'spotweb')[self.server_type == NewznabConstants.SERVER_SPOTWEB])
+
def check_cap_update(self):
if self.enabled and \
(not self._caps or (datetime.datetime.now() - self._caps_last_updated) >= datetime.timedelta(days=1)):
@@ -224,6 +236,12 @@ class NewznabProvider(generic.NZBProvider):
all_cats = []
xml_caps = self._get_caps_data()
if None is not xml_caps:
+ server_node = xml_caps.find('.//server')
+ if None is not server_node:
+ self.server_type = (NewznabConstants.SERVER_DEFAULT, NewznabConstants.SERVER_SPOTWEB)[
+ NewznabConstants.server_types.get(NewznabConstants.SERVER_SPOTWEB) in
+ (server_node.get('type', '') or server_node.get('title', '')).lower()]
+
tv_search = xml_caps.find('.//tv-search')
if None is not tv_search:
for c in [i for i in tv_search.get('supportedParams', '').split(',')]:
@@ -341,10 +359,10 @@ class NewznabProvider(generic.NZBProvider):
return True
def config_str(self):
- return '%s|%s|%s|%s|%i|%s|%i|%i|%i|%i' \
+ return '%s|%s|%s|%s|%i|%s|%i|%i|%i|%i|%i' \
% (self.name or '', self.url or '', self.maybe_apikey() or '', self.cat_ids or '', self.enabled,
self.search_mode or '', self.search_fallback, self.enable_recentsearch, self.enable_backlog,
- self.enable_scheduled_backlog)
+ self.enable_scheduled_backlog, self.server_type)
def _season_strings(self, ep_obj):
diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py
index ed288b12..be8684f2 100644
--- a/sickbeard/webserve.py
+++ b/sickbeard/webserve.py
@@ -6408,6 +6408,9 @@ class ConfigProviders(Config):
if attr_check in kwargs:
setattr(nzb_src, attr, str(kwargs.get(attr_check) or '').strip())
else:
+ new_provider.enabled = True
+ _ = new_provider.caps # when adding a custom, trigger server_type update
+ new_provider.enabled = False
sickbeard.newznabProviderList.append(new_provider)
active_ids.append(cur_id)