mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 13:43:37 +00:00
Merge pull request #1106 from JackDandy/feature/ChangeNewznabServerType
Detect newznab server type so that Spotweb is listed as (sw nzb) with…
This commit is contained in:
commit
9db9948c1a
6 changed files with 49 additions and 38 deletions
BIN
gui/slick/images/providers/spotweb.png
Normal file
BIN
gui/slick/images/providers/spotweb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1,013 B |
|
@ -2,6 +2,7 @@
|
||||||
#from sickbeard.clients import get_client_instance
|
#from sickbeard.clients import get_client_instance
|
||||||
#from sickbeard.providers.generic import GenericProvider
|
#from sickbeard.providers.generic import GenericProvider
|
||||||
#from sickbeard.providers import thepiratebay
|
#from sickbeard.providers import thepiratebay
|
||||||
|
#from sickbeard.providers.newznab import NewznabConstants
|
||||||
#from sickbeard.helpers import anon_url, starify
|
#from sickbeard.helpers import anon_url, starify
|
||||||
##
|
##
|
||||||
#set global $title = 'Config - Providers'
|
#set global $title = 'Config - Providers'
|
||||||
|
@ -95,6 +96,7 @@
|
||||||
#set $cur_name = $cur_provider.get_id()
|
#set $cur_name = $cur_provider.get_id()
|
||||||
#set $cur_url = $cur_provider.url
|
#set $cur_url = $cur_provider.url
|
||||||
#set $show_type = $sickbeard.USE_NZBS and $sickbeard.USE_TORRENTS and $GenericProvider.NZB == $cur_provider.providerType
|
#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 $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()],
|
#set $tip = ($cur_provider.name + ('', ' (enable for link)')[not $cur_url and not cur_provider.is_enabled()],
|
||||||
'Site Down')[$bad_url]
|
'Site Down')[$bad_url]
|
||||||
|
@ -106,7 +108,7 @@
|
||||||
#if $cur_provider.is_public_access() and type($cur_provider).__name__ not in ['TorrentRssProvider']#
|
#if $cur_provider.is_public_access() and type($cur_provider).__name__ not in ['TorrentRssProvider']#
|
||||||
<span style="font-size:10px;vertical-align:top;font-weight:normal">(PA)</span>
|
<span style="font-size:10px;vertical-align:top;font-weight:normal">(PA)</span>
|
||||||
#end if##if $show_type##slurp
|
#end if##if $show_type##slurp
|
||||||
<span style="font-size:10px;vertical-align:top;font-weight:normal">($cur_provider.providerType)</span>
|
<span style="font-size:10px;vertical-align:top;font-weight:normal">($spotweb$cur_provider.providerType)</span>
|
||||||
#end if##if not $cur_provider.supports_backlog#*#set $backlog_only_tip=True##end if##slurp
|
#end if##if not $cur_provider.supports_backlog#*#set $backlog_only_tip=True##end if##slurp
|
||||||
<span class="ui-icon ui-icon-arrowthick-2-n-s pull-right" style="margin-top:3px"></span>
|
<span class="ui-icon ui-icon-arrowthick-2-n-s pull-right" style="margin-top:3px"></span>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -44,6 +44,7 @@ from sickbeard.common import SD, SKIPPED
|
||||||
from sickbeard.databases import mainDB, cache_db, failed_db
|
from sickbeard.databases import mainDB, cache_db, failed_db
|
||||||
from sickbeard.exceptions import ex
|
from sickbeard.exceptions import ex
|
||||||
from sickbeard.providers.generic import GenericProvider
|
from sickbeard.providers.generic import GenericProvider
|
||||||
|
from sickbeard.providers.newznab import NewznabConstants
|
||||||
from sickbeard.watchedstate import EmbyWatchedStateUpdater, PlexWatchedStateUpdater
|
from sickbeard.watchedstate import EmbyWatchedStateUpdater, PlexWatchedStateUpdater
|
||||||
from indexers.indexer_config import INDEXER_TVDB
|
from indexers.indexer_config import INDEXER_TVDB
|
||||||
from indexers.indexer_api import indexerApi
|
from indexers.indexer_api import indexerApi
|
||||||
|
@ -1275,7 +1276,7 @@ def initialize(console_logging=True):
|
||||||
('api_key', ''), ('username', ''),
|
('api_key', ''), ('username', ''),
|
||||||
('scene_only', False), ('scene_or_contain', ''), ('scene_loose', False), ('scene_loose_active', False),
|
('scene_only', False), ('scene_or_contain', ''), ('scene_loose', False), ('scene_loose_active', False),
|
||||||
('scene_rej_nuked', False), ('scene_nuked_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):
|
if hasattr(nzb_prov, attr):
|
||||||
attr_check = '%s_%s' % (prov_id, attr.strip('_'))
|
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',
|
for attr in [x for x in ['enable_recentsearch', 'enable_backlog', 'enable_scheduled_backlog',
|
||||||
'scene_only', 'scene_loose', 'scene_loose_active',
|
'scene_only', 'scene_loose', 'scene_loose_active',
|
||||||
'scene_rej_nuked', 'scene_nuked_active',
|
'scene_rej_nuked', 'scene_nuked_active',
|
||||||
'search_fallback']
|
'search_fallback', 'server_type']
|
||||||
if hasattr(src, x)]:
|
if hasattr(src, x)]:
|
||||||
new_config[src_id_uc]['%s_%s' % (src_id, attr)] = helpers.tryInt(getattr(src, attr, None))
|
new_config[src_id_uc]['%s_%s' % (src_id, attr)] = helpers.tryInt(getattr(src, attr, None))
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import os.path
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
from . import generic
|
from . import generic
|
||||||
|
from .newznab import NewznabConstants
|
||||||
from sickbeard import logger, encodingKludge as ek
|
from sickbeard import logger, encodingKludge as ek
|
||||||
# usenet
|
# usenet
|
||||||
from . import newznab, omgwtfnzbs
|
from . import newznab, omgwtfnzbs
|
||||||
|
@ -151,14 +152,10 @@ def getNewznabProviderList(data):
|
||||||
providerList.append(curDefault)
|
providerList.append(curDefault)
|
||||||
else:
|
else:
|
||||||
providerDict[curDefault.name].default = True
|
providerDict[curDefault.name].default = True
|
||||||
providerDict[curDefault.name].name = curDefault.name
|
for k in ('name', 'url', 'needs_auth', 'search_mode', 'search_fallback',
|
||||||
providerDict[curDefault.name].url = curDefault.url
|
'enable_recentsearch', 'enable_backlog', 'enable_scheduled_backlog',
|
||||||
providerDict[curDefault.name].needs_auth = curDefault.needs_auth
|
'server_type'):
|
||||||
providerDict[curDefault.name].search_mode = curDefault.search_mode
|
setattr(providerDict[curDefault.name], k, getattr(curDefault, k))
|
||||||
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
|
|
||||||
|
|
||||||
return filter(lambda x: x, providerList)
|
return filter(lambda x: x, providerList)
|
||||||
|
|
||||||
|
@ -167,34 +164,24 @@ def makeNewznabProvider(configString):
|
||||||
if not configString:
|
if not configString:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
search_mode = 'eponly'
|
|
||||||
search_fallback = 0
|
|
||||||
enable_recentsearch = 0
|
|
||||||
enable_backlog = 0
|
|
||||||
enable_scheduled_backlog = 1
|
|
||||||
|
|
||||||
try:
|
|
||||||
values = configString.split('|')
|
values = configString.split('|')
|
||||||
if len(values) == 10:
|
if 5 <= len(values):
|
||||||
name, url, key, cat_ids, enabled, search_mode, search_fallback, enable_recentsearch, enable_backlog, \
|
name, url, enabled = values.pop(0), values.pop(0), values.pop(4-2)
|
||||||
enable_scheduled_backlog = values
|
params = dict()
|
||||||
elif len(values) == 9:
|
for k, d in (('key', ''), ('cat_ids', ''), ('search_mode', 'eponly'), ('search_fallback', 0),
|
||||||
name, url, key, cat_ids, enabled, search_mode, search_fallback, enable_recentsearch, enable_backlog = values
|
('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:
|
else:
|
||||||
name = values[0]
|
logger.log(u'Skipping Newznab provider string: \'%s\', incorrect format' % configString, logger.ERROR)
|
||||||
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)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
newznab = sys.modules['sickbeard.providers.newznab']
|
newznab = sys.modules['sickbeard.providers.newznab']
|
||||||
|
|
||||||
newProvider = newznab.NewznabProvider(name, url, key=key, cat_ids=cat_ids, search_mode=search_mode,
|
newProvider = newznab.NewznabProvider(name, url, **params)
|
||||||
search_fallback=search_fallback, enable_recentsearch=enable_recentsearch,
|
|
||||||
enable_backlog=enable_backlog, enable_scheduled_backlog=enable_scheduled_backlog)
|
|
||||||
newProvider.enabled = enabled == '1'
|
newProvider.enabled = enabled == '1'
|
||||||
|
|
||||||
return newProvider
|
return newProvider
|
||||||
|
|
|
@ -92,6 +92,12 @@ class NewznabConstants:
|
||||||
'season': SEARCH_SEASON,
|
'season': SEARCH_SEASON,
|
||||||
'ep': SEARCH_EPISODE}
|
'ep': SEARCH_EPISODE}
|
||||||
|
|
||||||
|
SERVER_DEFAULT = 0
|
||||||
|
SERVER_SPOTWEB = 1
|
||||||
|
|
||||||
|
server_types = {SERVER_DEFAULT: 'newznab',
|
||||||
|
SERVER_SPOTWEB: 'spotweb'}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -99,11 +105,12 @@ class NewznabConstants:
|
||||||
class NewznabProvider(generic.NZBProvider):
|
class NewznabProvider(generic.NZBProvider):
|
||||||
|
|
||||||
def __init__(self, name, url, key='', cat_ids=None, search_mode=None, search_fallback=False,
|
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)
|
generic.NZBProvider.__init__(self, name, True, False)
|
||||||
|
|
||||||
self.url = url
|
self.url = url
|
||||||
self.key = key
|
self.key = key
|
||||||
|
self.server_type = tryInt(server_type, None) or NewznabConstants.SERVER_DEFAULT
|
||||||
self._exclude = set()
|
self._exclude = set()
|
||||||
self.cat_ids = cat_ids or ''
|
self.cat_ids = cat_ids or ''
|
||||||
self._cat_ids = None
|
self._cat_ids = None
|
||||||
|
@ -185,6 +192,11 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
pass
|
pass
|
||||||
self._last_recent_search = value
|
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):
|
def check_cap_update(self):
|
||||||
if self.enabled and \
|
if self.enabled and \
|
||||||
(not self._caps or (datetime.datetime.now() - self._caps_last_updated) >= datetime.timedelta(days=1)):
|
(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 = []
|
all_cats = []
|
||||||
xml_caps = self._get_caps_data()
|
xml_caps = self._get_caps_data()
|
||||||
if None is not xml_caps:
|
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')
|
tv_search = xml_caps.find('.//tv-search')
|
||||||
if None is not tv_search:
|
if None is not tv_search:
|
||||||
for c in [i for i in tv_search.get('supportedParams', '').split(',')]:
|
for c in [i for i in tv_search.get('supportedParams', '').split(',')]:
|
||||||
|
@ -341,10 +359,10 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def config_str(self):
|
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.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.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):
|
def _season_strings(self, ep_obj):
|
||||||
|
|
||||||
|
|
|
@ -6408,6 +6408,9 @@ class ConfigProviders(Config):
|
||||||
if attr_check in kwargs:
|
if attr_check in kwargs:
|
||||||
setattr(nzb_src, attr, str(kwargs.get(attr_check) or '').strip())
|
setattr(nzb_src, attr, str(kwargs.get(attr_check) or '').strip())
|
||||||
else:
|
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)
|
sickbeard.newznabProviderList.append(new_provider)
|
||||||
|
|
||||||
active_ids.append(cur_id)
|
active_ids.append(cur_id)
|
||||||
|
|
Loading…
Reference in a new issue