Skip to content

Commit

Permalink
Refresh menu if the stream is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister committed Mar 26, 2020
1 parent b48f52a commit 960b07a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -957,3 +957,7 @@ msgstr ""
msgctxt "#30986"
msgid "No on demand stream available for {title}."
msgstr ""

msgctxt "#30987"
msgid "No stream found, please try again!"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -957,3 +957,7 @@ msgstr "VRT tokens werden verwijderd."
msgctxt "#30986"
msgid "No on demand stream available for {title}."
msgstr "Geen on demand stream beschikbaar voor {title}."

msgctxt "#30987"
msgid "No stream found, please try again!"
msgstr "Geen stream gevonden, gelieve opnieuw te proberen!"
10 changes: 8 additions & 2 deletions resources/lib/streamservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from urllib2 import build_opener, install_opener, urlopen, ProxyHandler, quote, unquote, HTTPError

from helperobjects import ApiData, StreamURLS
from kodiutils import (addon_profile, can_play_drm, exists, end_of_directory, get_max_bandwidth,
from kodiutils import (addon_profile, can_play_drm, container_reload, exists, end_of_directory, get_max_bandwidth,
get_proxies, get_setting_bool, get_url_json, has_inputstream_adaptive,
kodi_version, localize, log, log_error, mkdir, ok_dialog, open_settings,
invalidate_caches, kodi_version, localize, log, log_error, mkdir, ok_dialog, open_settings,
supports_drm, to_unicode)


Expand Down Expand Up @@ -261,6 +261,12 @@ def get_stream(self, video, roaming=False, api_data=None):

message = localize(30964) # Geoblock error: Cannot be played, need Belgian phone number validation
return self._handle_stream_api_error(message, stream_json)
elif stream_json.get('code') == 'VIDEO_NOT_FOUND':
# Refresh listing
invalidate_caches('*.json')
container_reload()
message = localize(30987) # No stream found
return self._handle_stream_api_error(message, stream_json)

# Failed to get stream, handle error
message = localize(30954) # Whoops something went wrong
Expand Down
12 changes: 12 additions & 0 deletions tests/test_streamservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ def test_get_ondemand_stream_from_invalid_url(self):
else:
self.assertEqual(None, stream)

@unittest.skipUnless(addon.settings.get('username'), 'Skipping as VRT username is missing.')
@unittest.skipUnless(addon.settings.get('password'), 'Skipping as VRT password is missing.')
def test_get_ondemand_stream_from_invalid_videoid(self):
"""Test getting stream from invalid video_id"""
video = dict(video_url=None, video_id='invalid_vid-4662107f-fc26-4f66-9076-984ee4bb80ee', publication_id='pbs-pub-be74b2e3-5054-4e4c-b8aa-42e9cd4877b6')
try:
stream = self._streamservice.get_stream(video)
except HTTPError:
pass
else:
self.assertEqual(None, stream)

@unittest.skipUnless(addon.settings.get('username'), 'Skipping as VRT username is missing.')
@unittest.skipUnless(addon.settings.get('password'), 'Skipping as VRT password is missing.')
def test_get_ondemand_stream_from_url_gets_stream_does_not_crash(self):
Expand Down

0 comments on commit 960b07a

Please sign in to comment.