Change disable connection attempts and remove UI references to the TVRage info source.

Change TVDB to be the default indexer if selected indexer is not configured active.
Change add dummyIndexer for inactive Indexers.
Change don't update show for indexer that are marked inactive.
This commit is contained in:
Prinz23 2015-12-17 00:35:39 +01:00 committed by JackDandy
parent 9444c49bda
commit 0bbaefe17b
10 changed files with 106 additions and 20 deletions

View file

@ -103,6 +103,7 @@
* Add option to create season search exceptions from editShow page
* Change sab to use requests library
* Add "View Changes" to tools menu
* Change disable connection attempts and remove UI references to the TVRage info source
### 0.10.0 (2015-08-06 11:05:00 UTC)

View file

@ -122,22 +122,22 @@
</span>
</label>
</div>
#if 1 < $len($indexers)
<div class="field-pair">
<label for="indexer_default">
<span class="component-title">Use initial indexer set to</span>
<span class="component-desc">
<select id="indexer_default" name="indexer_default" class="form-control input-sm">
<option value="0"#echo ('', $selected)[0 == $indexer]#>All Indexers</option>
#for $indexer in $sickbeard.indexerApi().indexers
#for $indexer in $indexers
<option value="$indexer"#echo ('', $selected)[$indexer == $sickbeard.INDEXER_DEFAULT]#>$sickbeard.indexerApi().indexers[$indexer]</option>
#end for
#end for
</select>
<span>as the default selection when adding new shows</span>
</span>
</label>
</div>
#end if
<div class="field-pair">
<label for="indexer_timeout">
<span class="component-title">Timeout show indexer at</span>
@ -636,7 +636,7 @@
<span class="component-title">Use proxy for indexers</span>
<span class="component-desc">
<input type="checkbox" name="proxy_indexers" id="proxy_indexers"#echo ('', $checked)[True == $sickbeard.PROXY_INDEXERS]#>
<p>use proxy host for connecting to indexers (thetvdb, tvrage)</p>
<p>use proxy host for TV info source connections</p>
</span>
</label>
</div>

View file

@ -31,13 +31,16 @@
#set $indexer = $curDir['existing_info'][2]
#end if
#set $indexer = $sickbeard.INDEXER_DEFAULT
#*
#set $indexer = 0
#if $curDir['existing_info'][0]
#set $indexer = $curDir['existing_info'][2]
#elif 0 < $sickbeard.INDEXER_DEFAULT
#set $indexer = $sickbeard.INDEXER_DEFAULT
#end if
*#
<tr>
<td class="col-checkbox">
<input type="checkbox" id="$show_id" class="dirCheck" checked=checked>
@ -58,7 +61,9 @@
<td align="center">
<select name="indexer">
#for $curIndexer in $sickbeard.indexerApi().indexers.items()
#if $curIndexer[0] == $sickbeard.INDEXER_DEFAULT
<option value="$curIndexer[0]" #if $curIndexer[0] == $indexer then 'selected="selected"' else ''#>$curIndexer[1]</option>
#end if
#end for
</select>
</td>

View file

@ -49,20 +49,29 @@
<input type="hidden" id="providedName" value="$provided_indexer_name" />
<input type="hidden" id="providedIndexer" value="$provided_indexer" />
#else
#if 2 > $len($indexers)
<style>
#addShowForm input#nameToSearch{width:611px}
</style>
<input type="hidden" id="providedIndexer" value="$provided_indexer" />
#end if
<input type="text" id="nameToSearch" value="$default_show_name" class="form-control form-control-inline input-sm input350" />
&nbsp;
<span style="float:right">
<select name="indexerLang" id="indexerLangSelect" class="form-control form-control-inline input-sm">
<option value="en" selected="selected">en</option>
</select><b>&nbsp;*</b>
<select name="providedIndexer" id="providedIndexer" class="form-control form-control-inline input-sm">
<option value="0" #if $provided_indexer == 0 then "selected=\"selected\"" else ""#>All Indexers</option>
#for $indexer in $indexers
<option value="$indexer" #if $provided_indexer == $indexer then "selected=\"selected\"" else ""#>$indexers[$indexer]</option>
#end for
</select>
&nbsp;
<input class="btn btn-inline" type="button" id="searchName" value="Search" />
<select name="indexerLang" id="indexerLangSelect" class="form-control form-control-inline input-sm">
<option value="en" selected="selected">en</option>
</select><b>&nbsp;*</b>
#if 1 < $len($indexers)
<select name="providedIndexer" id="providedIndexer" class="form-control form-control-inline input-sm">
<option value="0" #if $provided_indexer == 0 then "selected=\"selected\"" else ""#>All Indexers</option>
#for $indexer in $indexers
<option value="$indexer" #if $provided_indexer == $indexer then "selected=\"selected\"" else ""#>$indexers[$indexer]</option>
#end for
</select>
#end if
&nbsp;
<input class="btn btn-inline" type="button" id="searchName" value="Search" />
</span>
<br />
<p style="margin:5px 0 15px">Enter show name, TVDB ID, IMDb Url, or IMDb ID.&nbsp;&nbsp;<b>*</b>SickGear supports english, language is used for show/episode data</p>

View file

@ -38,6 +38,7 @@ from sickbeard import helpers, logger, db, naming, metadata, providers, scene_ex
from sickbeard.config import CheckSection, check_setting_int, check_setting_str, ConfigMigrator, minimax
from sickbeard.common import SD, SKIPPED
from sickbeard.databases import mainDB, cache_db, failed_db
from indexers.indexer_config import INDEXER_TVDB
from indexers.indexer_api import indexerApi
from indexers.indexer_exceptions import indexer_shownotfound, indexer_exception, indexer_error, \
indexer_episodenotfound, indexer_attributenotfound, indexer_seasonnotfound, indexer_userabort, indexerExcepts
@ -667,6 +668,8 @@ def initialize(consoleLogging=True):
NOTIFY_ON_UPDATE = bool(check_setting_int(CFG, 'General', 'notify_on_update', 1))
FLATTEN_FOLDERS_DEFAULT = bool(check_setting_int(CFG, 'General', 'flatten_folders_default', 0))
INDEXER_DEFAULT = check_setting_int(CFG, 'General', 'indexer_default', 0)
if INDEXER_DEFAULT and not indexerApi(INDEXER_DEFAULT).config['active']:
INDEXER_DEFAULT = INDEXER_TVDB
INDEXER_TIMEOUT = check_setting_int(CFG, 'General', 'indexer_timeout', 20)
ANIME_DEFAULT = bool(check_setting_int(CFG, 'General', 'anime_default', 0))
SCENE_DEFAULT = bool(check_setting_int(CFG, 'General', 'scene_default', 0))

View file

@ -17,10 +17,63 @@
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import os
import sickbeard
import time
from indexer_config import initConfig, indexerConfig
from sickbeard.helpers import proxy_setting
class ShowContainer(dict):
"""Simple dict that holds a series of Show instances
"""
def __init__(self):
self._stack = []
self._lastgc = time.time()
def __setitem__(self, key, value):
self._stack.append(key)
# keep only the 100th latest results
if time.time() - self._lastgc > 20:
for o in self._stack[:-100]:
del self[o]
self._stack = self._stack[-100:]
self._lastgc = time.time()
super(ShowContainer, self).__setitem__(key, value)
class DummyIndexer:
def __init__(self, *args, **kwargs):
self.config = {
'apikey': '',
'debug_enabled': False,
'custom_ui': None,
'proxy': None,
'cache_enabled': False,
'cache_location': '',
'valid_languages': [],
'langabbv_to_id': {},
'language': 'en',
'base_url': '',
}
self.corrections = {}
self.shows = ShowContainer()
def __getitem__(self, key):
return None
def __repr__(self):
return str(self.shows)
def search(self, series):
return []
class indexerApi(object):
def __init__(self, indexerID=None):
self.indexerID = int(indexerID) if indexerID else None
@ -30,7 +83,10 @@ class indexerApi(object):
def indexer(self, *args, **kwargs):
if self.indexerID:
return indexerConfig[self.indexerID]['module'](*args, **kwargs)
if indexerConfig[self.indexerID]['active']:
return indexerConfig[self.indexerID]['module'](*args, **kwargs)
else:
return DummyIndexer(*args, **kwargs)
@property
def config(self):

View file

@ -25,6 +25,7 @@ indexerConfig[INDEXER_TVDB] = {
'language': 'en',
'useZip': True,
},
'active': True,
}
indexerConfig[INDEXER_TVRAGE] = {
@ -34,6 +35,7 @@ indexerConfig[INDEXER_TVRAGE] = {
'api_params': {'apikey': 'Uhewg1Rr0o62fvZvUIZt',
'language': 'en',
},
'active': False,
}
# TVDB Indexer Settings

View file

@ -556,7 +556,7 @@ class GenericProvider:
value *= 1024 ** ['b', 'k', 'm', 'g', 't'].index(re.findall('(t|g|m|k)[i]?b', size_dim.lower())[0])
except IndexError:
pass
return int(math.ceil(value))
return long(math.ceil(value))
class NZBProvider(object, GenericProvider):

View file

@ -578,6 +578,11 @@ class QueueItemUpdate(ShowQueueItem):
ShowQueueItem.run(self)
if not sickbeard.indexerApi(self.show.indexer).config['active']:
logger.log(u'Indexer %s is marked inactive, aborting update for show %s and continue with refresh.' % (sickbeard.indexerApi(self.show.indexer).config['name'], self.show.name))
sickbeard.showQueueScheduler.action.refreshShow(self.show, self.force, self.scheduled_update, after_update=True)
return
logger.log(u'Beginning update of ' + self.show.name)
logger.log(u'Retrieving show info from ' + sickbeard.indexerApi(self.show.indexer).name + '', logger.DEBUG)

View file

@ -2316,7 +2316,8 @@ class NewHomeAddShows(Home):
t.provided_show_dir = show_dir
t.other_shows = other_shows
t.provided_indexer = int(indexer or sickbeard.INDEXER_DEFAULT)
t.indexers = sickbeard.indexerApi().indexers
t.indexers = dict([(i, sickbeard.indexerApi().indexers[i]) for i in sickbeard.indexerApi().indexers
if sickbeard.indexerApi(i).config['active']])
t.whitelist = []
t.blacklist = []
t.groups = []
@ -3744,6 +3745,8 @@ class ConfigGeneral(Config):
t = PageTemplate(headers=self.request.headers, file='config_general.tmpl')
t.submenu = self.ConfigMenu
t.show_tags = ', '.join(sickbeard.SHOW_TAGS)
t.indexers = dict([(i, sickbeard.indexerApi().indexers[i]) for i in sickbeard.indexerApi().indexers
if sickbeard.indexerApi(i).config['active']])
return t.respond()
def saveRootDirs(self, rootDirString=None):
@ -3876,6 +3879,8 @@ class ConfigGeneral(Config):
if indexer_default:
sickbeard.INDEXER_DEFAULT = config.to_int(indexer_default)
if not sickbeard.indexerApi(sickbeard.INDEXER_DEFAULT).config['active']:
sickbeard.INDEXER_DEFAULT = INDEXER_TVDB
if indexer_timeout:
sickbeard.INDEXER_TIMEOUT = config.to_int(indexer_timeout)