Add TVDB, TheXem, and GitHub buttons to page History/Layout "Provider fails" that fetches a site Up/Down report.

This commit is contained in:
JackDandy 2018-05-30 15:24:40 +01:00
parent e440155b2c
commit 7028bb2f4a
6 changed files with 113 additions and 5 deletions

View file

@ -1,9 +1,10 @@
### 0.17.0 (2018-xx-xx xx:xx:xx UTC) ### 0.17.0 (2018-xx-xx xx:xx:xx UTC)
* Change add "Keep up to x most recent downloads" to Edit Show/Other * Add TVDB, TheXem, and GitHub buttons to page History/Layout "Provider fails" that fetches a site Up/Down report
* Change add "Keep up to x most recent downloads" to Manage/Bulk Change/Edit * Add "Keep up to x most recent downloads" to Edit Show/Other
* Add "Keep up to x most recent downloads" to Manage/Bulk Change/Edit
* Change append number of downloads to keep to the number of file(s) at Display Show * Change append number of downloads to keep to the number of file(s) at Display Show
* Change add "Keep up to x most recent downloads" to add show finally step * Add "Keep up to x most recent downloads" to add show finally step
* Add prune to refreshDir/rescan * Add prune to refreshDir/rescan
* Update Tornado Web Server 5.0.1 (35a538f) to 5.0.1 (2b2a220a) * Update Tornado Web Server 5.0.1 (35a538f) to 5.0.1 (2b2a220a)
* Add HDME torrent provider * Add HDME torrent provider

View file

@ -3282,6 +3282,9 @@ input.get_less_eps{
margin:0 6px 0 0; margin:0 6px 0 0;
min-width:70px min-width:70px
} }
#provider-failures .check-site .btn{
min-width:115px
}
#media-search .btn.shows-more, #media-search .btn.shows-more,
#media-search .btn.shows-less, #media-search .btn.shows-less,
#provider-failures .btn.shows-more, #provider-failures .btn.shows-more,
@ -3604,6 +3607,23 @@ img[src=""],img:not([src]){
top:-999px top:-999px
} }
.box-green{
background-color:#68b92b
}
.box-red{
background-color:#b72828
}
.box-green,
.box-red{
color:#eee;
padding:0 10px;
text-align:center;
text-decoration:none;
border-radius:4px 4px 4px 4px;
-moz-border-radius:3px;
-webkit-border-radius:3px
}
/* ======================================================================= /* =======================================================================
bootstrap Overrides bootstrap Overrides
========================================================================== */ ========================================================================== */

BIN
gui/slick/images/iidrn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

View file

@ -589,8 +589,19 @@
## ##
## ##
<div id="provider-failures"> <div id="provider-failures">
#for ($check, $check_name, $check_url) in [
('tvdb', 'TVDB Api', 'api.thetvdb.com'), ('thexem', 'The Xem', 'thexem.de'), ('github', 'GitHub', 'github.com'),
]
<div id="check-$check" data-check="check_$check" class="check-site" style="margin-bottom:10px">
<input type="button" class="btn" value="Check $check_name">
<span style="line-height:26px">Test if site is up<span class="result"></span>
<a class="addQTip" style="margin-left:2px;display:none" href="$sickbeard.helpers.anon_url('http://www.isitdownrightnow.com/downorjustme.php?url=' + $check_url)" rel="noreferrer" onclick="window.open(this.href, '_blank'); return !1;" title="View full report for $check_name in new tab"><img alt="[IsItDown]" height="16" width="16" src="$sbRoot/images/iidrn.png" /></a>
</span>
</div>
#end for
#if not $provider_fails #if not $provider_fails
<p>No current failures. Failure stats display here when appropriate.</p> <p>No current provider failures. Failure stats display here when appropriate.</p>
#else #else
<p>When a provider cannot be contacted over a period, SickGear backs off and waits an increasing interval between each retry</p> <p>When a provider cannot be contacted over a period, SickGear backs off and waits an increasing interval between each retry</p>
#for $prov in $provider_fail_stats #for $prov in $provider_fail_stats

View file

@ -186,6 +186,49 @@ $(document).ready(function() {
$.SickGear.sumChecked(); $.SickGear.sumChecked();
}); });
function updown(data){
var result = ': <span class="grey-text">failed to test site, oh the irony!</span>';
if(!(/undefined/i.test(data))) {
// noinspection JSUnresolvedVariable
var resp = data.last_down;
if (!(/undefined/i.test(resp))) {
result = ': <span class="grey-text"> yes it\'s <span class="box-green">up</span> and was last down ' + resp + ' ago</span>';
} else {
// noinspection JSUnresolvedVariable
resp = data.down_for;
if (!(/undefined/i.test(resp))) {
result = ': <span class="red-text">no, it\'s been <span class="box-red">down</span> for ~' + resp + '</span>';
}
}
}
return result;
}
function check_site(clicked){
var that = $(clicked), el$=$(that.parent());
that.attr('disabled', !0);
$.ajax({
url: $.SickGear.Root + '/history/check_site/?site_name=' + el$.attr('data-check'),
type: 'GET',
dataType: 'json',
complete: function (data) {
// noinspection JSUnresolvedVariable
el$.find('.result').html(updown(data.responseJSON));
el$.find('a').show();
that.attr('disabled', !1);
}
});
}
$.each(['tvdb', 'thexem', 'github'], function(i, el_id){
$('#check-' + el_id).find('input').click(function(){
check_site(this);
});
});
$('.shows-less').click(function(){ $('.shows-less').click(function(){
var table$ = $(this).nextAll('table:first'); var table$ = $(this).nextAll('table:first');
table$ = table$.length ? table$ : $(this).parent().nextAll('table:first'); table$ = table$.length ? table$ : $(this).parent().nextAll('table:first');

View file

@ -5329,6 +5329,39 @@ class History(MainHandler):
return t.respond() return t.respond()
def check_site(self, site_name='', *args, **kwargs):
site_url = dict(
tvdb='api.thetvdb.com', thexem='thexem.de', github='github.com'
).get(site_name.replace('check_', ''))
result = {}
if site_url:
resp = helpers.getURL('https://www.isitdownrightnow.com/check.php?domain=%s' % site_url)
if resp:
check = resp.lower()
day = re.findall(r'(\d+)\s*(?:day)', check)
hr = re.findall(r'(\d+)\s*(?:hour)', check)
mn = re.findall(r'(\d+)\s*(?:min)', check)
if any([day, hr, mn]):
period = ', '.join(
(day and ['%sd' % day[0]] or day)
+ (hr and ['%sh' % hr[0]] or hr)
+ (mn and ['%sm' % mn[0]] or mn))
else:
try:
period = re.findall('[^>]>([^<]+)ago', check)[0].strip()
except (StandardError, Exception):
try:
period = re.findall('[^>]>([^<]+week)', check)[0]
except (StandardError, Exception):
period = 'quite some time'
result = {('last_down', 'down_for')['up' not in check and 'down for' in check]: period}
return json.dumps(result)
def clearHistory(self, *args, **kwargs): def clearHistory(self, *args, **kwargs):
myDB = db.DBConnection() myDB = db.DBConnection()