diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index c45e97f1..996864e1 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -617,10 +617,6 @@ msgctxt "#30952" msgid "Invalid email adress or password. Only VRT logins are supported, no Google or Facebook logins." msgstr "" -msgctxt "#30953" -msgid "This program cannot be played. To view this program outside of Belgium, you first have to validate a Belgian mobile phone number on the VRT NU website." -msgstr "" - msgctxt "#30954" msgid "Whoops something went wrong, check the kodi log for more details." msgstr "" @@ -720,3 +716,11 @@ msgstr "" msgctxt "#30986" msgid "No on demand stream available for %s." msgstr "" + +msgctxt "#30990" +msgid "This program cannot be played. To view this program outside of Belgium, you first have to validate a Belgian mobile phone number on the VRT NU website." +msgstr "" + +msgctxt "#30991" +msgid "This program cannot be played. It is blocked on your geographical location based on your IP address. More info at https://www.vrt.be/vrtnu/help/country/" +msgstr "" diff --git a/resources/language/resource.language.nl_nl/strings.po b/resources/language/resource.language.nl_nl/strings.po index 70ab2287..5c3c4aa6 100644 --- a/resources/language/resource.language.nl_nl/strings.po +++ b/resources/language/resource.language.nl_nl/strings.po @@ -509,10 +509,6 @@ msgctxt "#30952" msgid "Invalid email adress or password. Only VRT logins are supported, no Google or Facebook logins." msgstr "Ongeldig e-mailadres of wachtwoord. Alleen VRT-logins worden ondersteund, geen Google- of Facebook-logins." -msgctxt "#30953" -msgid "This program cannot be played. To view this program outside of Belgium, you first have to validate a Belgian mobile phone number on the VRT NU website." -msgstr "Dit programma kan niet afgespeeld worden. Om dit programma buiten Belgiƫ te bekijken moet je eerst een Belgisch gsm-nummer valideren via de VRT NU-website." - msgctxt "#30954" msgid "Whoops something went wrong, check the kodi log for more details." msgstr "Oeps, er ging iets mis, check de kodi log voor meer informatie." @@ -612,3 +608,11 @@ msgstr "VRT tokens werden verwijderd." msgctxt "#30986" msgid "No on demand stream available for %s." msgstr "Geen on demand stream beschikbaar voor %s" + +msgctxt "#30990" +msgid "This program cannot be played. To view this program outside of Belgium, you first have to validate a Belgian mobile phone number on the VRT NU website." +msgstr "Dit programma kan niet afgespeeld worden. Om dit programma buiten Belgiƫ te bekijken moet je eerst een Belgisch gsm-nummer valideren via de VRT NU-website." + +msgctxt "#30991" +msgid "This program cannot be played. It is blocked on your geographical location based on your IP address. More info at https://www.vrt.be/vrtnu/help/country/" +msgstr "Dit programma kan niet afgespeeld worden. Het wordt geblokkeerd op jouw geografische locatie op basis van je IP-adres. Meer info op https://www.vrt.be/vrtnu/help/country/" diff --git a/resources/lib/streamservice.py b/resources/lib/streamservice.py index ab3076ca..dbcf3d89 100644 --- a/resources/lib/streamservice.py +++ b/resources/lib/streamservice.py @@ -25,7 +25,10 @@ class StreamService: _VUALTO_API_URL = 'https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1' _CLIENT = 'vrtvideo' _UPLYNK_LICENSE_URL = 'https://content.uplynk.com/wv' - _GEOBLOCK_ERROR_CODES = ('INCOMPLETE_ROAMING_CONFIG', 'INVALID_LOCATION') + _INVALID_LOCATION = 'INVALID_LOCATION' + _INCOMPLETE_ROAMING_CONFIG = 'INCOMPLETE_ROAMING_CONFIG' + _GEOBLOCK_ERROR_CODES = (_INCOMPLETE_ROAMING_CONFIG, _INVALID_LOCATION) + def __init__(self, _kodi, _tokenresolver): ''' Initialize Stream Service class ''' @@ -192,8 +195,16 @@ def get_stream(self, video, roaming=False, api_data=None): api_data = self._get_api_data(video) stream_json = self._get_stream_json(api_data, roaming) + if not stream_json: - return None + + # Roaming token failed + if roaming: + message = self._kodi.localize(30990) # Geoblock error: Cannot be played, need Belgian phone number validation + return self._handle_stream_api_error(message) + + message = self._kodi.localize(30954) # Whoops something went wrong + return self._handle_stream_api_error(message) if 'targetUrls' in stream_json: @@ -255,16 +266,21 @@ def get_stream(self, video, roaming=False, api_data=None): if not roaming: return self.get_stream(video, roaming=True, api_data=api_data) - message = self._kodi.localize(30953) # Geoblock error: Cannot be played, need Belgian phone number validation - return self._handle_stream_api_error(stream_json, message) + if stream_json.get('code') == self._INVALID_LOCATION: + message = self._kodi.localize(30991) # Geoblock error: Blocked on your geographical location based on your IP address + return self._handle_stream_api_error(message, stream_json) + + message = self._kodi.localize(30990) # Geoblock error: Cannot be played, need Belgian phone number validation + return self._handle_stream_api_error(message, stream_json) # Failed to get stream, handle error message = self._kodi.localize(30954) # Whoops something went wrong - return self._handle_stream_api_error(stream_json, message) + return self._handle_stream_api_error(message, stream_json) - def _handle_stream_api_error(self, video_json, message): + def _handle_stream_api_error(self, message, video_json=None): ''' Show localized stream api error messages in Kodi GUI ''' - self._kodi.log_error(video_json.get('message')) + if video_json: + self._kodi.log_error(video_json.get('message')) self._kodi.show_ok_dialog(message=message) self._kodi.end_of_directory()