Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add page-browsing to recent menu #177

Merged
merged 1 commit into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def router(params_string):
vrt_player.show_livestream_items()
elif action == actions.LISTING_EPISODES:
vrt_player.show_episodes(path=params.get('video_url'))
elif action == actions.LISTING_RECENT:
vrt_player.show_recent(page=params.get('page'))
elif action == actions.LISTING_CATEGORY_TVSHOWS:
vrt_player.show_tvshow_menu_items(path=params.get('video_url'))
elif action == actions.PLAY:
Expand Down
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 @@ -155,6 +155,10 @@ msgctxt "#32204"
msgid "[B][COLOR green](%s hours left)[/COLOR][/B]\n"
msgstr "[B][COLOR green](%s hours left)[/COLOR][/B]\n"

msgctxt "#32300"
msgid "[B][COLOR yellow]More...[/COLOR][/B]"
msgstr "[B][COLOR yellow]More...[/COLOR][/B]"

msgctxt "#32301"
msgid "[B]TV guide for channel %s[/B]"
msgstr "[B]TV guide for channel %s[/B]"
Expand Down
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 @@ -156,6 +156,10 @@ msgctxt "#32204"
msgid "[B][COLOR green](%s hours left)[/COLOR][/B]\n"
msgstr "[B][COLOR green](nog %s uur)[/COLOR][/B]\n"

msgctxt "#32300"
msgid "[B][COLOR yellow]More...[/COLOR][/B]"
msgstr "[B][COLOR yellow]Meer...[/COLOR][/B]"

msgctxt "#32301"
msgid "[B]TV guide for channel %s[/B]"
msgstr "[B]TV-gids for kanaal %s[/B]"
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/vrtplayer/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

LISTING_AZ_TVSHOWS = 'listingaztvshows'
LISTING_CATEGORIES = 'listingcategories'
LISTING_LIVE = 'listinglive'

LISTING_CATEGORY_TVSHOWS = 'listingcategorytvshows'
LISTING_EPISODES = 'listingepisodes'
LISTING_LIVE = 'listinglive'
LISTING_RECENT = 'listingrecent'
LISTING_TVGUIDE = 'listingtvguide'

PLAY = 'play'
15 changes: 10 additions & 5 deletions resources/lib/vrtplayer/vrtapihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,28 @@ def _get_season_items(self, api_url, api_json):
season_items, sort, ascending = self._map_to_season_items(api_url, facet.get('buckets', []), episode)
return season_items, sort, ascending

def get_episode_items(self, path):
def get_episode_items(self, path=None, page=None):
import json
episode_items = []
sort = 'episode'
ascending = True
if path == 'recent':

# Recent items
if page:
entries = 50
params = {
'from': (page - 1) * entries,
'i': 'video',
'size': '100',
'size': entries,
'facets[transcodingStatus]': 'AVAILABLE',
'facets[brands]': '[een,canvas,sporza,vrtnws,vrtnxt,radio1,radio2,klara,stubru,mnm]',
}
api_url = self._VRTNU_SEARCH_URL + '?' + urlencode(params)
# api_json = requests.get(api_url, proxies=self._proxies).json()
api_json = json.loads(urlopen(api_url).read())
episode_items, sort, ascending = self._map_to_episode_items(api_json.get('results', []), path)
else:
episode_items, sort, ascending = self._map_to_episode_items(api_json.get('results', []), titletype='recent')

if path:
if '.relevant/' in path:
params = {
'i': 'video',
Expand Down
21 changes: 19 additions & 2 deletions resources/lib/vrtplayer/vrtplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def show_main_menu_items(self):
art_dict=dict(thumb='DefaultAddonPVRClient.png', icon='DefaultAddonPVRClient.png', fanart='DefaultAddonPVRClient.png'),
video_dict=dict(plot=self._kodi_wrapper.get_localized_string(32085))),
helperobjects.TitleItem(title=self._kodi_wrapper.get_localized_string(32086),
url_dict=dict(action=actions.LISTING_EPISODES, video_url='recent'),
url_dict=dict(action=actions.LISTING_RECENT, page='1'),
is_playable=False,
art_dict=dict(thumb='DefaultYear.png', icon='DefaultYear.png', fanart='DefaultYear.png'),
video_dict=dict(plot=self._kodi_wrapper.get_localized_string(32087))),
Expand Down Expand Up @@ -130,7 +130,24 @@ def show_livestream_items(self):
self._kodi_wrapper.show_listing(livestream_items, cache=False)

def show_episodes(self, path):
episode_items, sort, ascending = self._api_helper.get_episode_items(path)
episode_items, sort, ascending = self._api_helper.get_episode_items(path=path)
self._kodi_wrapper.show_listing(episode_items, sort=sort, ascending=ascending, content_type='episodes')

def show_recent(self, page):
try:
page = int(page)
except TypeError:
page = 1

episode_items, sort, ascending = self._api_helper.get_episode_items(page=page)

# Add 'More...' entry at the end
episode_items.append(helperobjects.TitleItem(title=self._kodi_wrapper.get_localized_string(32300),
url_dict=dict(action=actions.LISTING_RECENT, page=page + 1),
is_playable=False,
art_dict=dict(thumb='DefaultYear.png', icon='DefaultYear.png', fanart='DefaultYear.png'),
video_dict=dict()))

self._kodi_wrapper.show_listing(episode_items, sort=sort, ascending=ascending, content_type='episodes', cache=False)

def play(self, params):
Expand Down
15 changes: 7 additions & 8 deletions test/vrtplayertests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TestVRTPlayer(unittest.TestCase):

def test_show_videos_single_episode_shows_videos(self):
path = '/vrtnu/a-z/marathonradio.relevant/'
episode_items, sort, ascending = self._api_helper.get_episode_items(path)
episode_items, sort, ascending = self._api_helper.get_episode_items(path=path)
self.assertTrue(episode_items, msg=path)
self.assertEqual(sort, 'dateadded')
self.assertFalse(ascending)
Expand All @@ -30,7 +30,7 @@ def test_show_videos_single_episode_shows_videos(self):

def test_show_videos_single_season_shows_videos(self):
path = '/vrtnu/a-z/het-weer.relevant/'
episode_items, sort, ascending = self._api_helper.get_episode_items(path)
episode_items, sort, ascending = self._api_helper.get_episode_items(path=path)
self.assertTrue(episode_items, msg=path)
self.assertEqual(sort, 'dateadded')
self.assertFalse(ascending)
Expand All @@ -41,7 +41,7 @@ def test_show_videos_single_season_shows_videos(self):

def test_show_videos_multiple_seasons_shows_videos(self):
path = '/vrtnu/a-z/pano.relevant/'
episode_items, sort, ascending = self._api_helper.get_episode_items(path)
episode_items, sort, ascending = self._api_helper.get_episode_items(path=path)
self.assertTrue(episode_items)
self.assertEqual(sort, 'label')
self.assertFalse(ascending)
Expand All @@ -52,7 +52,7 @@ def test_show_videos_multiple_seasons_shows_videos(self):

def test_show_videos_specific_seasons_shows_videos(self):
path = '/vrtnu/a-z/thuis.relevant/'
episode_items, sort, ascending = self._api_helper.get_episode_items(path)
episode_items, sort, ascending = self._api_helper.get_episode_items(path=path)
self.assertTrue(episode_items, msg=path)
self.assertEqual(sort, 'label')
self.assertFalse(ascending)
Expand All @@ -63,16 +63,15 @@ def test_show_videos_specific_seasons_shows_videos(self):

def test_get_recent_episodes(self):
''' Test items, sort and order '''
path = 'recent'
episode_items, sort, ascending = self._api_helper.get_episode_items(path)
self.assertTrue(episode_items)
episode_items, sort, ascending = self._api_helper.get_episode_items(page=1)
self.assertEqual(len(episode_items), 50)
self.assertEqual(sort, 'dateadded')
self.assertFalse(ascending)

def test_get_program_episodes(self):
''' Test items, sort and order '''
path = '/vrtnu/a-z/het-journaal.relevant/'
episode_items, sort, ascending = self._api_helper.get_episode_items(path)
episode_items, sort, ascending = self._api_helper.get_episode_items(path=path)
self.assertTrue(episode_items)
self.assertEqual(sort, 'dateadded')
self.assertFalse(ascending)
Expand Down