mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-03 18:03: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>
|
||||
<th style="text-align:left">Show name</th>
|
||||
<th>Last found</th>
|
||||
<th>No warn icon</th>
|
||||
</tr>
|
||||
#set $row = 0
|
||||
#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>
|
||||
</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>
|
||||
#end for
|
||||
</tbody>
|
||||
|
|
|
@ -117,7 +117,7 @@ class TVShow(object):
|
|||
self._overview = ''
|
||||
self._tag = ''
|
||||
self._mapped_ids = {}
|
||||
self._not_found_count = -1
|
||||
self._not_found_count = None
|
||||
self._last_found_on_indexer = -1
|
||||
|
||||
self.dirty = True
|
||||
|
@ -166,7 +166,7 @@ class TVShow(object):
|
|||
tag = property(lambda self: self._tag, dirty_setter('_tag'))
|
||||
|
||||
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()
|
||||
results = myDB.select('SELECT fail_count, last_success FROM tv_shows_not_found WHERE indexer = ? AND indexer_id = ?',
|
||||
[self.indexer, self.indexerid])
|
||||
|
@ -184,7 +184,22 @@ class TVShow(object):
|
|||
|
||||
@not_found_count.setter
|
||||
def not_found_count(self, v):
|
||||
self._not_found_count = 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
|
||||
|
||||
@property
|
||||
def last_found_on_indexer(self):
|
||||
|
@ -193,24 +208,20 @@ class TVShow(object):
|
|||
|
||||
def inc_not_found_count(self):
|
||||
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])
|
||||
days = (show_not_found_retry_days - 1, 0)[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 self.not_found_count <= 0:
|
||||
last_success = self.last_update_indexer
|
||||
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})
|
||||
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():
|
||||
self.not_found_count += (-1, 1)[0 <= self.not_found_count]
|
||||
|
||||
def reset_not_found_count(self):
|
||||
if self.not_found_count > 0:
|
||||
if 0 != self.not_found_count:
|
||||
self._not_found_count = 0
|
||||
self._last_found_on_indexer = 0
|
||||
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
|
||||
def ids(self):
|
||||
|
@ -382,7 +393,8 @@ class TVShow(object):
|
|||
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 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
|
||||
|
||||
myDB = db.DBConnection()
|
||||
|
|
|
@ -96,6 +96,7 @@ class PageTemplate(Template):
|
|||
self.sbThemeName = sickbeard.THEME_NAME
|
||||
|
||||
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.menu = [
|
||||
{'title': 'Home', 'key': 'home'},
|
||||
|
@ -1319,7 +1320,7 @@ class Home(MainHandler):
|
|||
elif sickbeard.showQueueScheduler.action.isInSubtitleQueue(showObj): # @UndefinedVariable
|
||||
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(
|
||||
showObj.last_found_on_indexer).sbfdate())[1 < showObj.last_found_on_indexer]
|
||||
show_message = (
|
||||
|
@ -1784,12 +1785,12 @@ class Home(MainHandler):
|
|||
self.fanart_tmpl(t)
|
||||
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'))
|
||||
|
||||
show_message = ''
|
||||
|
||||
if 0 < showObj.not_found_count:
|
||||
if 0 != showObj.not_found_count:
|
||||
# noinspection PyUnresolvedReferences
|
||||
last_found = ('', ' since %s' % sbdatetime.sbdatetime.fromordinal(
|
||||
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
|
||||
|
||||
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:
|
||||
date = helpers.tryInt(s['last_success'])
|
||||
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')]
|
||||
sql_r = None
|
||||
if defunct_indexer:
|
||||
|
@ -4639,6 +4641,18 @@ class showProcesses(Manage):
|
|||
time.sleep(5)
|
||||
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):
|
||||
def index(self, limit=100):
|
||||
|
|
Loading…
Reference in a new issue