Skip to content

Commit

Permalink
Add page-browsing to recent menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister authored and dagwieers committed May 3, 2019
1 parent 3f6015d commit cda870b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
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: 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'
17 changes: 13 additions & 4 deletions resources/lib/vrtplayer/vrtapihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,32 @@ 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 = 75
try:
page = int(page)
except TypeError:
page = 1
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:

if path:
if '.relevant/' in path:
params = {
'i': 'video',
Expand Down
8 changes: 6 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,11 @@ 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):
episode_items, sort, ascending = self._api_helper.get_episode_items(page=page)
self._kodi_wrapper.show_listing(episode_items, sort=sort, ascending=ascending, content_type='episodes', cache=False)

def play(self, params):
Expand Down

0 comments on commit cda870b

Please sign in to comment.