mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-02 17:33:37 +00:00
Detect newznab server type so that Spotweb is listed as (sw nzb) with a specific default image.
This commit is contained in:
parent
5565a2bfae
commit
0da750aa4d
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.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']#
|
||||
<span style="font-size:10px;vertical-align:top;font-weight:normal">(PA)</span>
|
||||
#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
|
||||
<span class="ui-icon ui-icon-arrowthick-2-n-s pull-right" style="margin-top:3px"></span>
|
||||
</li>
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue