diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 77860d4a..148cda3c 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -967,7 +967,7 @@ msgid "No connection" msgstr "" msgctxt "#30969" -msgid "There is a problem connecting to the Internet. This could be related to Kodi, your network, your ISP or VRT NU. Check out the Kodi log for more details." +msgid "There is a problem connecting to the Internet. This could be related to Kodi, your network, your ISP or VRT NU. Check out the Kodi log for more details.\n[COLOR=yellow]{reason}[/COLOR]" msgstr "" msgctxt "#30970" diff --git a/resources/language/resource.language.nl_nl/strings.po b/resources/language/resource.language.nl_nl/strings.po index 6fd9a9fb..b8bf529f 100644 --- a/resources/language/resource.language.nl_nl/strings.po +++ b/resources/language/resource.language.nl_nl/strings.po @@ -967,8 +967,8 @@ msgid "No connection" msgstr "Geen verbinding" msgctxt "#30969" -msgid "There is a problem connecting to the Internet. This could be related to Kodi, your network, your ISP or VRT NU. Check out the Kodi log for more details." -msgstr "Er is een probleem met het verbinden met internet. Dit kan liggen aan Kodi, aan jouw netwerk, aan jouw ISP of aan VRT NU. Bekijk de Kodi-log voor meer details." +msgid "There is a problem connecting to the Internet. This could be related to Kodi, your network, your ISP or VRT NU. Check out the Kodi log for more details.\n[COLOR=yellow]{reason}[/COLOR]" +msgstr "Er is een probleem met het verbinden met internet. Dit kan liggen aan Kodi, aan jouw netwerk, aan jouw ISP of aan VRT NU. Bekijk de Kodi-log voor meer details.\n[COLOR=yellow]{reason}[/COLOR]" msgctxt "#30970" msgid "VRT NU authentication failed" diff --git a/resources/lib/apihelper.py b/resources/lib/apihelper.py index 01761131..2d0c9791 100644 --- a/resources/lib/apihelper.py +++ b/resources/lib/apihelper.py @@ -596,6 +596,10 @@ def get_episodes(self, program=None, season=None, episodes=None, category=None, else: search_json = get_url_json(url=search_url, fail={}) + # Fail more gracefully on network errors + if not search_json: + return [] + # Check for multiple seasons seasons = [] if 'facets[seasonTitle]' not in unquote(search_url): diff --git a/resources/lib/kodiutils.py b/resources/lib/kodiutils.py index ce8046e6..63825e72 100644 --- a/resources/lib/kodiutils.py +++ b/resources/lib/kodiutils.py @@ -4,9 +4,9 @@ from __future__ import absolute_import, division, unicode_literals from contextlib import contextmanager -from sys import version_info from socket import timeout from ssl import SSLError +from sys import exit as sysexit, version_info import xbmc import xbmcaddon @@ -1094,48 +1094,48 @@ def open_url(url, data=None, headers=None, method=None, cookiejar=None, follow_r else: # Python 2.7 url_length = len(req.get_selector()) if exc.code == 400 and 7600 <= url_length <= 8192: - ok_dialog(heading='HTTP Error 400', message=localize(30967)) + ok_dialog(heading='HTTP Error 400: {reason}'.format(reason=exc.reason), message=localize(30967)) log_error('HTTP Error 400: Probably exceeded maximum url length: ' 'VRT Search API url has a length of {length} characters.', length=url_length) - return None + sysexit('HTTP Error 400') if exc.code == 413 and url_length > 8192: - ok_dialog(heading='HTTP Error 413', message=localize(30967)) + ok_dialog(heading='HTTP Error 413: {reason}'.format(reason=exc.reason), message=localize(30967)) log_error('HTTP Error 413: Exceeded maximum url length: ' 'VRT Search API url has a length of {length} characters.', length=url_length) - return None + sysexit('HTTP Error 413') if exc.code == 431: - ok_dialog(heading='HTTP Error 431', message=localize(30967)) + ok_dialog(heading='HTTP Error 431: {reason}'.format(reason=exc.reason), message=localize(30967)) log_error('HTTP Error 431: Request header fields too large: ' 'VRT Search API url has a length of {length} characters.', length=url_length) - return None + sysexit('HTTP Error 431') if exc.code == 401: - ok_dialog(heading='HTTP Error {code}'.format(code=exc.code), message='{}\n{}'.format(url, exc.reason)) + ok_dialog(heading='HTTP Error 401: {reason}'.format(reason=exc.reason), message='{}\n{}'.format(url, exc.reason)) log_error('HTTP Error {code}: {reason}', code=exc.code, reason=exc.reason) return None if exc.code in (400, 403) and exc.headers.get('Content-Type') and 'application/json' in exc.headers.get('Content-Type'): return exc - reason = exc.reason - code = exc.code - ok_dialog(heading='HTTP Error {code}'.format(code=code), message='{}\n{}'.format(url, reason)) - log_error('HTTP Error {code}: {reason}', code=code, reason=reason) + ok_dialog(heading='HTTP Error {code}: {reason}'.format(code=exc.code, reason=exc.reason), message='{}\n{}'.format(url, exc.reason)) + log_error('HTTP Error {code}: {reason}', code=exc.code, reason=exc.reason) return None except URLError as exc: - ok_dialog(heading=localize(30968), message=localize(30969)) - log_error('URLError: {error}\nurl: {url}', error=exc.reason, url=url) + ok_dialog(heading=localize(30968), message=localize(30969, reason=exc.reason)) + log_error('URLError: {reason}\nurl: {url}', reason=exc.reason, url=url) return None except SSLError as exc: # TODO: Include the error message in the notification window - ok_dialog(heading=localize(30968), message=localize(30969)) if hasattr(exc, 'reason'): # Python 2.7.9+, but still failed on Python 2.7.16 - log_error('SSLError: {error} ({library})\nurl: {url}', error=exc.reason, library=exc.library, url=url) + ok_dialog(heading=localize(30968), message=localize(30969, reason=exc.reason)) + log_error('SSLError: {reason} ({library})\nurl: {url}', reason=exc.reason, library=exc.library, url=url) elif isinstance(exc, list): - log_error('SSLError: {error} ({errno})\nurl: {url}', errno=exc[0], error=exc[1], url=url) + ok_dialog(heading=localize(30968), message=localize(30969, reason='{e[1]} ({e[0]})'.format(e=exc))) + log_error('SSLError: {reason} ({errno})\nurl: {url}', errno=exc[0], reason=exc[1], url=url) else: - log_error('SSLError: {error}\nurl: {url}', error=str(exc), url=url) + ok_dialog(heading=localize(30968), message=localize(30969, reason=str(exc))) + log_error('SSLError: {reason}\nurl: {url}', reason=str(exc), url=url) return None except timeout as exc: - ok_dialog(heading=localize(30968), message=localize(30969)) - log_error('Timeout: {error}\nurl: {url}', error=exc.reason, url=url) + ok_dialog(heading=localize(30968), message=localize(30969, reason=exc.reason)) + log_error('Timeout: {reason}\nurl: {url}', reason=exc.reason, url=url) return None