mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 21:53:37 +00:00
Change add switchIgnoreWarning and log_num_not_found_shows to PageTemplate.
This commit is contained in:
parent
8173ae4628
commit
75f59d717e
3 changed files with 51 additions and 21 deletions
|
@ -35,6 +35,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th style="text-align:left">Show name</th>
|
<th style="text-align:left">Show name</th>
|
||||||
<th>Last found</th>
|
<th>Last found</th>
|
||||||
|
<th>No warn icon</th>
|
||||||
</tr>
|
</tr>
|
||||||
#set $row = 0
|
#set $row = 0
|
||||||
#for $cur_show in $NotFoundShows:
|
#for $cur_show in $NotFoundShows:
|
||||||
|
@ -43,6 +44,9 @@
|
||||||
<a class="whitelink" href="$sbRoot/home/displayShow?show=$cur_show['indexer_id']">$cur_show['show_name']</a>
|
<a class="whitelink" href="$sbRoot/home/displayShow?show=$cur_show['indexer_id']">$cur_show['show_name']</a>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:20%;text-align:center;color:white">$cur_show['last_success']</td>
|
<td style="width:20%;text-align:center;color:white">$cur_show['last_success']</td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" #if $cur_show['ignore_warning'] then 'checked="checked"' else ''#>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
#end for
|
#end for
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -117,7 +117,7 @@ class TVShow(object):
|
||||||
self._overview = ''
|
self._overview = ''
|
||||||
self._tag = ''
|
self._tag = ''
|
||||||
self._mapped_ids = {}
|
self._mapped_ids = {}
|
||||||
self._not_found_count = -1
|
self._not_found_count = None
|
||||||
self._last_found_on_indexer = -1
|
self._last_found_on_indexer = -1
|
||||||
|
|
||||||
self.dirty = True
|
self.dirty = True
|
||||||
|
@ -166,7 +166,7 @@ class TVShow(object):
|
||||||
tag = property(lambda self: self._tag, dirty_setter('_tag'))
|
tag = property(lambda self: self._tag, dirty_setter('_tag'))
|
||||||
|
|
||||||
def _helper_load_failed_db(self):
|
def _helper_load_failed_db(self):
|
||||||
if self._not_found_count == -1 or self._last_found_on_indexer == -1:
|
if None is self._not_found_count or self._last_found_on_indexer == -1:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
results = myDB.select('SELECT fail_count, last_success FROM tv_shows_not_found WHERE indexer = ? AND indexer_id = ?',
|
results = myDB.select('SELECT fail_count, last_success FROM tv_shows_not_found WHERE indexer = ? AND indexer_id = ?',
|
||||||
[self.indexer, self.indexerid])
|
[self.indexer, self.indexerid])
|
||||||
|
@ -184,6 +184,21 @@ class TVShow(object):
|
||||||
|
|
||||||
@not_found_count.setter
|
@not_found_count.setter
|
||||||
def not_found_count(self, v):
|
def not_found_count(self, v):
|
||||||
|
if isinstance(v, (int, long)) and v != self._not_found_count:
|
||||||
|
self._last_found_on_indexer = self.last_found_on_indexer
|
||||||
|
myDB = db.DBConnection()
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
|
last_check = sbdatetime.now().totimestamp(default=0)
|
||||||
|
# in case of flag change (+/-) don't change last_check date
|
||||||
|
if abs(v) == abs(self._not_found_count):
|
||||||
|
results = myDB.select('SELECT last_check FROM tv_shows_not_found WHERE indexer = ? AND indexer_id = ?',
|
||||||
|
[self.indexer, self.indexerid])
|
||||||
|
if results:
|
||||||
|
last_check = helpers.tryInt(results[0]['last_check'])
|
||||||
|
myDB.upsert('tv_shows_not_found',
|
||||||
|
{'fail_count': v, 'last_check': last_check,
|
||||||
|
'last_success': self._last_found_on_indexer},
|
||||||
|
{'indexer': self.indexer, 'indexer_id': self.indexerid})
|
||||||
self._not_found_count = v
|
self._not_found_count = v
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -193,24 +208,20 @@ class TVShow(object):
|
||||||
|
|
||||||
def inc_not_found_count(self):
|
def inc_not_found_count(self):
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
results = myDB.select('SELECT fail_count, last_check, last_success FROM tv_shows_not_found WHERE indexer = ? AND indexer_id = ?',
|
results = myDB.select('SELECT last_check FROM tv_shows_not_found WHERE indexer = ? AND indexer_id = ?',
|
||||||
[self.indexer, self.indexerid])
|
[self.indexer, self.indexerid])
|
||||||
days = (show_not_found_retry_days - 1, 0)[self.not_found_count <= concurrent_show_not_found_days]
|
days = (show_not_found_retry_days - 1, 0)[abs(self.not_found_count) <= concurrent_show_not_found_days]
|
||||||
if not results or datetime.datetime.fromtimestamp(helpers.tryInt(results[0]['last_check'])) + datetime.timedelta(days=days, hours=18) < datetime.datetime.now():
|
if not results or datetime.datetime.fromtimestamp(helpers.tryInt(results[0]['last_check'])) + \
|
||||||
if self.not_found_count <= 0:
|
datetime.timedelta(days=days, hours=18) < datetime.datetime.now():
|
||||||
last_success = self.last_update_indexer
|
self.not_found_count += (-1, 1)[0 <= self.not_found_count]
|
||||||
else:
|
|
||||||
last_success = helpers.tryInt(results[0]['last_success'], self.last_update_indexer)
|
|
||||||
self._last_found_on_indexer = last_success
|
|
||||||
self.not_found_count += 1
|
|
||||||
myDB.upsert('tv_shows_not_found', {'fail_count': self.not_found_count, 'last_check': sbdatetime.now().totimestamp(default=0), 'last_success': last_success},
|
|
||||||
{'indexer': self.indexer, 'indexer_id': self.indexerid})
|
|
||||||
|
|
||||||
def reset_not_found_count(self):
|
def reset_not_found_count(self):
|
||||||
if self.not_found_count > 0:
|
if 0 != self.not_found_count:
|
||||||
self._not_found_count = 0
|
self._not_found_count = 0
|
||||||
|
self._last_found_on_indexer = 0
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.action('DELETE FROM tv_shows_not_found WHERE indexer = ? AND indexer_id = ?', [self.indexer, self.indexerid])
|
myDB.action('DELETE FROM tv_shows_not_found WHERE indexer = ? AND indexer_id = ?',
|
||||||
|
[self.indexer, self.indexerid])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ids(self):
|
def ids(self):
|
||||||
|
@ -382,7 +393,8 @@ class TVShow(object):
|
||||||
last_update_indexer = datetime.date.fromordinal(self.last_update_indexer)
|
last_update_indexer = datetime.date.fromordinal(self.last_update_indexer)
|
||||||
|
|
||||||
# if show was not found for 1 week, only retry to update once a week
|
# if show was not found for 1 week, only retry to update once a week
|
||||||
if concurrent_show_not_found_days < self.not_found_count and (update_date - last_update_indexer) < datetime.timedelta(days=show_not_found_retry_days):
|
if (concurrent_show_not_found_days < abs(self.not_found_count)) \
|
||||||
|
and (update_date - last_update_indexer) < datetime.timedelta(days=show_not_found_retry_days):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
|
|
|
@ -96,6 +96,7 @@ class PageTemplate(Template):
|
||||||
self.sbThemeName = sickbeard.THEME_NAME
|
self.sbThemeName = sickbeard.THEME_NAME
|
||||||
|
|
||||||
self.log_num_errors = len(classes.ErrorViewer.errors)
|
self.log_num_errors = len(classes.ErrorViewer.errors)
|
||||||
|
self.log_num_not_found_shows = len([x for x in sickbeard.showList if 0 < x.not_found_count])
|
||||||
self.sbPID = str(sickbeard.PID)
|
self.sbPID = str(sickbeard.PID)
|
||||||
self.menu = [
|
self.menu = [
|
||||||
{'title': 'Home', 'key': 'home'},
|
{'title': 'Home', 'key': 'home'},
|
||||||
|
@ -1319,7 +1320,7 @@ class Home(MainHandler):
|
||||||
elif sickbeard.showQueueScheduler.action.isInSubtitleQueue(showObj): # @UndefinedVariable
|
elif sickbeard.showQueueScheduler.action.isInSubtitleQueue(showObj): # @UndefinedVariable
|
||||||
show_message = 'This show is queued and awaiting subtitles download.'
|
show_message = 'This show is queued and awaiting subtitles download.'
|
||||||
|
|
||||||
if 0 < showObj.not_found_count:
|
if 0 != showObj.not_found_count:
|
||||||
last_found = ('', ' since %s' % sbdatetime.sbdatetime.fromordinal(
|
last_found = ('', ' since %s' % sbdatetime.sbdatetime.fromordinal(
|
||||||
showObj.last_found_on_indexer).sbfdate())[1 < showObj.last_found_on_indexer]
|
showObj.last_found_on_indexer).sbfdate())[1 < showObj.last_found_on_indexer]
|
||||||
show_message = (
|
show_message = (
|
||||||
|
@ -1784,12 +1785,12 @@ class Home(MainHandler):
|
||||||
self.fanart_tmpl(t)
|
self.fanart_tmpl(t)
|
||||||
t.num_ratings = len(sickbeard.FANART_RATINGS.get(str(t.show.indexerid), {}))
|
t.num_ratings = len(sickbeard.FANART_RATINGS.get(str(t.show.indexerid), {}))
|
||||||
|
|
||||||
t.unlock_master_id = 0 < showObj.not_found_count
|
t.unlock_master_id = 0 != showObj.not_found_count
|
||||||
t.showname_enc = urllib.quote_plus(showObj.name.encode('utf-8'))
|
t.showname_enc = urllib.quote_plus(showObj.name.encode('utf-8'))
|
||||||
|
|
||||||
show_message = ''
|
show_message = ''
|
||||||
|
|
||||||
if 0 < showObj.not_found_count:
|
if 0 != showObj.not_found_count:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
last_found = ('', ' since %s' % sbdatetime.sbdatetime.fromordinal(
|
last_found = ('', ' since %s' % sbdatetime.sbdatetime.fromordinal(
|
||||||
showObj.last_found_on_indexer).sbfdate())[1 < showObj.last_found_on_indexer]
|
showObj.last_found_on_indexer).sbfdate())[1 < showObj.last_found_on_indexer]
|
||||||
|
@ -4614,10 +4615,11 @@ class showProcesses(Manage):
|
||||||
t.ShowUpdateRunning = sickbeard.showQueueScheduler.action.isShowUpdateRunning() or sickbeard.showUpdateScheduler.action.amActive
|
t.ShowUpdateRunning = sickbeard.showQueueScheduler.action.isShowUpdateRunning() or sickbeard.showUpdateScheduler.action.amActive
|
||||||
|
|
||||||
myDb = db.DBConnection(row_type='dict')
|
myDb = db.DBConnection(row_type='dict')
|
||||||
sql_results = myDb.select('SELECT n.indexer, n.indexer_id, n.last_success, s.show_name FROM tv_shows_not_found as n INNER JOIN tv_shows as s ON (n.indexer == s.indexer AND n.indexer_id == s.indexer_id)')
|
sql_results = myDb.select('SELECT n.indexer, n.indexer_id, n.last_success, n.fail_count, s.show_name FROM tv_shows_not_found as n INNER JOIN tv_shows as s ON (n.indexer == s.indexer AND n.indexer_id == s.indexer_id)')
|
||||||
for s in sql_results:
|
for s in sql_results:
|
||||||
date = helpers.tryInt(s['last_success'])
|
date = helpers.tryInt(s['last_success'])
|
||||||
s['last_success'] = ('never', sbdatetime.sbdatetime.fromordinal(date).sbfdate())[date > 1]
|
s['last_success'] = ('never', sbdatetime.sbdatetime.fromordinal(date).sbfdate())[date > 1]
|
||||||
|
s['ignore_warning'] = 0 > s['fail_count']
|
||||||
defunct_indexer = [i for i in sickbeard.indexerApi().all_indexers if sickbeard.indexerApi(i).config.get('defunct')]
|
defunct_indexer = [i for i in sickbeard.indexerApi().all_indexers if sickbeard.indexerApi(i).config.get('defunct')]
|
||||||
sql_r = None
|
sql_r = None
|
||||||
if defunct_indexer:
|
if defunct_indexer:
|
||||||
|
@ -4639,6 +4641,18 @@ class showProcesses(Manage):
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
self.redirect('/manage/showProcesses/')
|
self.redirect('/manage/showProcesses/')
|
||||||
|
|
||||||
|
def switchIgnoreWarning(self, indexer=None, indexer_id=None, *args, **kwargs):
|
||||||
|
indexer = helpers.tryInt(indexer)
|
||||||
|
indexer_id = helpers.tryInt(indexer_id)
|
||||||
|
showObj = helpers.find_show_by_id(sickbeard.showList, {indexer: indexer_id})
|
||||||
|
|
||||||
|
if not showObj:
|
||||||
|
return json.dumps({'indexer': indexer, 'indexer_id': indexer_id, 'error': 'Show not found'})
|
||||||
|
|
||||||
|
showObj.not_found_count *= -1
|
||||||
|
|
||||||
|
return json.dumps({'indexer': indexer, 'indexer_id': indexer_id, 'ignore_warning': 0 > showObj.not_found_count})
|
||||||
|
|
||||||
|
|
||||||
class History(MainHandler):
|
class History(MainHandler):
|
||||||
def index(self, limit=100):
|
def index(self, limit=100):
|
||||||
|
|
Loading…
Reference in a new issue