diff --git a/bazarr/main.py b/bazarr/main.py index 2fcfae45b..c19977fe4 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -464,12 +464,18 @@ def api_movies_history(): def test_url(protocol, url): url = protocol + '://' + unquote(url) try: - result = requests.get(url, allow_redirects=False, verify=False).json()['version'] + result = requests.get(url, allow_redirects=False, verify=False, timeout=5) except Exception as e: - logging.exception('BAZARR cannot successfully contact this URL: ' + url) - return dict(status=False) + return dict(status=False, error=repr(e)) else: - return dict(status=True, version=result) + if result.status_code == 200: + return dict(status=True, version=result.json()['version']) + elif result.status_code == 401: + return dict(status=False, error='Access Denied. Check API key.') + elif 300 <= result.status_code <= 399: + return dict(status=False, error='Wrong URL Base.') + else: + return dict(status=False, error=result.raise_for_status()) @app.route('/test_notification//', methods=['GET']) diff --git a/views/settingsradarr.html b/views/settingsradarr.html index 2d0bbfb23..4c4ae9654 100644 --- a/views/settingsradarr.html +++ b/views/settingsradarr.html @@ -369,6 +369,7 @@ }); $('#test_radarr_connection').on('click', function() { + $('#test_radarr_span').html('
Loading...
'); if ($('#settings-radarr-ssl').is(':checked')) { var protocol = 'https'; } else { @@ -380,7 +381,7 @@ if (data.status) { $('#test_radarr_span').text('Test Successful: Radarr v' + data.version).css('color', 'green'); } else { - $('#test_radarr_span').text('Test Failed').css('color', 'red'); + $('#test_radarr_span').text('Test Failed: ' + data.error).css('color', 'red'); } }); }); diff --git a/views/settingssonarr.html b/views/settingssonarr.html index 5490de987..e1754e0ac 100644 --- a/views/settingssonarr.html +++ b/views/settingssonarr.html @@ -369,6 +369,7 @@ }); $('#test_sonarr_connection').on('click', function() { + $('#test_sonarr_span').html('
Loading...
'); if ($('#settings-sonarr-ssl').is(':checked')) { var protocol = 'https'; } else { @@ -380,7 +381,8 @@ if (data.status) { $('#test_sonarr_span').text('Test Successful: Sonarr v' + data.version).css('color', 'green'); } else { - $('#test_sonarr_span').text('Test Failed').css('color', 'red'); + console.log(data); + $('#test_sonarr_span').text('Test Failed: ' + data.error).css('color', 'red'); } }); });