Skip to content

Commit

Permalink
improved roaming handling (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister authored and dagwieers committed Jul 11, 2019
1 parent 07b5fc8 commit 4becfc0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
12 changes: 8 additions & 4 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 ""
12 changes: 8 additions & 4 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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/"
30 changes: 23 additions & 7 deletions resources/lib/streamservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '''
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 4becfc0

Please sign in to comment.