Commit 03766e8c authored by echel0n's avatar echel0n

Added health check to Torrent/NZB providers that looks for a http return code...

Added health check to Torrent/NZB providers that looks for a http return code of 200 using their base url.
Refactored misc function names.
parent bbbfe456
......@@ -279,7 +279,7 @@ class TVCache(object):
if not show_object:
continue
result = self.provider.getResult()
result = self.provider.get_result()
# ignore invalid and private IP address urls
if not validate_url(curResult["url"]):
......
......@@ -330,7 +330,7 @@ def search_providers(show_id, season, episode, manualSearch=False, downCurQualit
for providerID, providerObj in sickrage.app.search_providers.sort(randomize=sickrage.app.config.randomize_providers).items():
# check if provider is enabled
if not providerObj.isEnabled:
if not providerObj.is_enabled:
continue
# check provider type
......
......@@ -97,7 +97,7 @@ class ProperSearcher(object):
continue
elif not sickrage.app.config.use_torrents and providerObj.type in [TorrentProvider.type, TorrentRssProvider.type]:
continue
elif not providerObj.isEnabled:
elif not providerObj.is_enabled:
continue
threading.currentThread().setName(orig_thread_name + " :: [" + providerObj.name + "]")
......@@ -261,7 +261,7 @@ class ProperSearcher(object):
continue
# make the result object
result = curProper.provider.getResult(curProper.season, [curProper.episode])
result = curProper.provider.get_result(curProper.season, [curProper.episode])
result.show_id = curProper.indexer_id
result.url = curProper.url
result.name = curProper.name
......
......@@ -19,7 +19,7 @@ class RSSCacheUpdater(object):
threading.currentThread().setName(self.name)
for providerID, providerObj in sickrage.app.search_providers.sort().items():
if providerObj.isEnabled:
if providerObj.is_enabled:
sickrage.app.log.debug("Updating RSS cache for provider: [{}]".format(providerObj.name))
threading.currentThread().setName(self.name + "::[" + providerObj.name + "]")
providerObj.cache.update(force)
......
......@@ -98,7 +98,7 @@
<div class="align-middle">
<label class="form-check-label" for="enable_${providerID}">
<input type="checkbox" id="enable_${providerID}"
class="provider_enabler text-left" ${('', 'checked')[bool(providerObj.isEnabled)]}/>
class="provider_enabler text-left" ${('', 'checked')[bool(providerObj.is_enabled)]}/>
<a href="${anon_url(provider_url)}" class="text-right" rel="noreferrer"
onclick="window.open(this.href, '_blank'); return false;">
% if providerObj.type in ['nzb', 'torrent']:
......@@ -111,7 +111,7 @@
</label>
<span class="float-right d-inline-block">
${('<i class="text-warning fas fa-chevron-circle-left"></i>', '')[bool(providerObj.supports_backlog)]}
${('<i class="text-danger fas fa-exclamation-circle"></i>', '')[bool(providerObj.isAlive)]}
${('<i class="text-danger fas fa-exclamation-circle"></i>', '')[bool(providerObj.is_alive)]}
<i class="fas ${('fa-unlock text-success','fa-lock text-danger')[bool(providerObj.private)]}"></i>
</span>
</div>
......@@ -120,7 +120,7 @@
% endfor
</div>
<input type="hidden" name="provider_order" id="provider_order"
value="${"!!!".join(["{}:{}".format(providerID, int(providerObj.isEnabled)) for providerID, providerObj in sickrage.app.search_providers.all().items()])}"/>
value="${"!!!".join(["{}:{}".format(providerID, int(providerObj.is_enabled)) for providerID, providerObj in sickrage.app.search_providers.all().items()])}"/>
<input type="submit" class="btn config_submitter" value="${_('Save Changes')}"/>
</fieldset>
</div>
......
......@@ -90,11 +90,11 @@ class GenericProvider(object):
return str(re.sub(r"[^\w\d_]", "_", self.name.strip().lower()))
@property
def isEnabled(self):
def is_enabled(self):
return self.enabled
@property
def imageName(self):
def image_name(self):
return ""
@property
......@@ -102,8 +102,8 @@ class GenericProvider(object):
return ''
@property
def isAlive(self):
return True
def is_alive(self):
return self.session.get(self.urls['base_url']).ok
@property
def urls(self):
......@@ -122,7 +122,7 @@ class GenericProvider(object):
def login(self):
return True
def getResult(self, season=None, episodes=None):
def get_result(self, season=None, episodes=None):
"""
Returns a result of the correct type for this provider
"""
......@@ -313,7 +313,7 @@ class GenericProvider(object):
# filter results
for item in item_list:
provider_result = self.getResult()
provider_result = self.get_result()
provider_result.name, provider_result.url = self._get_title_and_url(item)
......@@ -405,7 +405,7 @@ class GenericProvider(object):
for term in self.proper_strings:
search_strngs = self._get_episode_search_strings(show_id, season, episode, add_string=term)
for item in self.search(search_strngs[0], show_id=show_id, season=season, episode=episode):
result = self.getResult(season, [episode])
result = self.get_result(season, [episode])
result.name, result.url = self._get_title_and_url(item)
if not validate_url(result.url) and not result.url.startswith('magnet'):
continue
......@@ -579,10 +579,10 @@ class TorrentProvider(GenericProvider):
@property
def isActive(self):
return sickrage.app.config.use_torrents and self.isEnabled
return sickrage.app.config.use_torrents and self.is_enabled
@property
def imageName(self):
def image_name(self):
return self.id
@property
......@@ -593,7 +593,7 @@ class TorrentProvider(GenericProvider):
"""
return self.ratio
def getResult(self, season=None, episodes=None):
def get_result(self, season=None, episodes=None):
"""
Returns a result of the correct type for this provider
"""
......@@ -738,13 +738,13 @@ class NZBProvider(GenericProvider):
@property
def isActive(self):
return sickrage.app.config.use_nzbs and self.isEnabled
return sickrage.app.config.use_nzbs and self.is_enabled
@property
def imageName(self):
def image_name(self):
return self.id
def getResult(self, season=None, episodes=None):
def get_result(self, season=None, episodes=None):
"""
Returns a result of the correct type for this provider
"""
......@@ -1306,10 +1306,10 @@ class SearchProviders(dict):
return OrderedDict([(x.id, x) for x in sorted_providers])
def enabled(self):
return dict([(pID, pObj) for pID, pObj in self.all().items() if pObj.isEnabled])
return dict([(pID, pObj) for pID, pObj in self.all().items() if pObj.is_enabled])
def disabled(self):
return dict([(pID, pObj) for pID, pObj in self.all().items() if not pObj.isEnabled])
return dict([(pID, pObj) for pID, pObj in self.all().items() if not pObj.is_enabled])
def all(self):
return {**self.nzb(), **self.torrent(), **self.newznab(), **self.torrentrss()}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment