From 7028bb2f4ac6d1357c508f2c0b08605ff9f538e8 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Wed, 30 May 2018 15:24:40 +0100 Subject: [PATCH] Add TVDB, TheXem, and GitHub buttons to page History/Layout "Provider fails" that fetches a site Up/Down report. --- CHANGES.md | 7 ++-- gui/slick/css/style.css | 20 ++++++++++ gui/slick/images/iidrn.png | Bin 0 -> 805 bytes gui/slick/interfaces/default/history.tmpl | 15 +++++++- gui/slick/js/history.js | 43 ++++++++++++++++++++++ sickbeard/webserve.py | 33 +++++++++++++++++ 6 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 gui/slick/images/iidrn.png diff --git a/CHANGES.md b/CHANGES.md index 439a6035..a0422a7d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,10 @@ ### 0.17.0 (2018-xx-xx xx:xx:xx UTC) -* Change add "Keep up to x most recent downloads" to Edit Show/Other -* Change add "Keep up to x most recent downloads" to Manage/Bulk Change/Edit +* Add TVDB, TheXem, and GitHub buttons to page History/Layout "Provider fails" that fetches a site Up/Down report +* 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 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 * Update Tornado Web Server 5.0.1 (35a538f) to 5.0.1 (2b2a220a) * Add HDME torrent provider diff --git a/gui/slick/css/style.css b/gui/slick/css/style.css index 3f1b045f..9d5aa02b 100644 --- a/gui/slick/css/style.css +++ b/gui/slick/css/style.css @@ -3282,6 +3282,9 @@ input.get_less_eps{ margin:0 6px 0 0; min-width:70px } +#provider-failures .check-site .btn{ + min-width:115px +} #media-search .btn.shows-more, #media-search .btn.shows-less, #provider-failures .btn.shows-more, @@ -3604,6 +3607,23 @@ img[src=""],img:not([src]){ 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 ========================================================================== */ diff --git a/gui/slick/images/iidrn.png b/gui/slick/images/iidrn.png new file mode 100644 index 0000000000000000000000000000000000000000..43e12d0217ed77f08bf50a9c4123027641ca2b6c GIT binary patch literal 805 zcmV+=1KRwFP) zyDm(ajKf}U1xpB3~p}^(r@qkqUo(Y zCjr2kE`5Ix%Ak!c+n^a1M;cIqh|0i)`)HVL?N)1FAnNKNN+c1N=TmfRV#o3dySAMC zq@(4{oHJjg(aBK+VI5BGH#oIlQ7;#f8y`pAUSY=d(9|WzB+mmA{d0p?Hyr+Q-}Y~} z&6Q@#fqsm_lTlRa58?YU0%C;Bh-y{nD1_D#h+;&wN=6EWH2`2Od77)41_OrD2*Pmb zHBeBbVTwlREkY$3L>d$Zs0?4)@$jb~9%Ki;I{TLZW-_H9q!3381+^q$hCv#E@4-+C z%mgo=MGyoeww=%^%eUGE(l zR7&wPi?T2`*ZKSD&%PPy>-Dd8zbHeUZE|D(J6BxSUHPnjEF&ToGpBQt + #for ($check, $check_name, $check_url) in [ + ('tvdb', 'TVDB Api', 'api.thetvdb.com'), ('thexem', 'The Xem', 'thexem.de'), ('github', 'GitHub', 'github.com'), + ] +
+ + Test if site is up + + +
+ #end for + #if not $provider_fails -

No current failures. Failure stats display here when appropriate.

+

No current provider failures. Failure stats display here when appropriate.

#else

When a provider cannot be contacted over a period, SickGear backs off and waits an increasing interval between each retry

#for $prov in $provider_fail_stats @@ -604,7 +615,7 @@ #else #set $prov_class = $prov_class % '' #end if - $prov_class$prov['name'] + $prov_class$prov['name'] #if $prov['active'] #if $prov['next_try'] #set nt = $str($prov['next_try']).split('.', 2)[0][::-1].replace(':', ' m', 1).replace(':', ' h', 1)[::-1] diff --git a/gui/slick/js/history.js b/gui/slick/js/history.js index 1ae8ae97..d53c331b 100644 --- a/gui/slick/js/history.js +++ b/gui/slick/js/history.js @@ -186,6 +186,49 @@ $(document).ready(function() { $.SickGear.sumChecked(); }); + function updown(data){ + var result = ': failed to test site, oh the irony!'; + + if(!(/undefined/i.test(data))) { + // noinspection JSUnresolvedVariable + var resp = data.last_down; + + if (!(/undefined/i.test(resp))) { + result = ': yes it\'s up and was last down ' + resp + ' ago'; + } else { + // noinspection JSUnresolvedVariable + resp = data.down_for; + if (!(/undefined/i.test(resp))) { + result = ': no, it\'s been down for ~' + resp + ''; + } + } + } + + 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(){ var table$ = $(this).nextAll('table:first'); table$ = table$.length ? table$ : $(this).parent().nextAll('table:first'); diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index b9629c4e..ed288b12 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -5329,6 +5329,39 @@ class History(MainHandler): 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): myDB = db.DBConnection()