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 fanart to menus #82

Merged
merged 1 commit into from Mar 21, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -4,12 +4,14 @@

class TitleItem:

def __init__(self, title, url_dictionary, is_playable, thumbnail=None, video_dictionary=None):
def __init__(self, title, url_dictionary, is_playable, thumbnail=None, video_dictionary=None, icon='', fanart=None):
self.title = title
self.url_dictionary = url_dictionary
self.is_playable = is_playable
self.thumbnail = thumbnail
self.video_dictionary = video_dictionary
self.icon = icon
self.fanart = self.fanart if self.fanart else self.thumbnail


class Credentials:
Expand Down
4 changes: 2 additions & 2 deletions plugin.video.vrt.nu/resources/lib/kodiwrappers/kodiwrapper.py
Expand Up @@ -28,12 +28,12 @@ def __init__(self, handle, url, addon):
def show_listing(self, list_items, sort=None):
listing = []
for title_item in list_items:
list_item = xbmcgui.ListItem(label=title_item.title)
list_item = xbmcgui.ListItem(label=title_item.title, iconImage=title_item.icon)
url = self._url + '?' + urlencode(title_item.url_dictionary)
list_item.setProperty('IsPlayable', str(title_item.is_playable))

if title_item.thumbnail is not None:
list_item.setArt({'thumb': title_item.thumbnail})
list_item.setArt({'thumb': title_item.thumbnail, 'fanart': title_item.fanart, 'icon': title_item.icon})

list_item.setInfo('video', title_item.video_dictionary)

Expand Down
58 changes: 36 additions & 22 deletions plugin.video.vrt.nu/resources/lib/vrtplayer/vrtplayer.py
Expand Up @@ -13,7 +13,7 @@ class VRTPlayer:

# URLs van https://services.vrt.be/videoplayer/r/live.json
_EEN_LIVESTREAM = 'https://www.vrt.be/vrtnu/kanalen/een/'
_CANVAS_LIVESTREAM_ = 'https://www.vrt.be/vrtnu/kanalen/canvas/'
_CANVAS_LIVESTREAM = 'https://www.vrt.be/vrtnu/kanalen/canvas/'
_KETNET_LIVESTREAM = 'https://www.vrt.be/vrtnu/kanalen/ketnet/'

VRT_BASE = 'https://www.vrt.be/'
Expand All @@ -27,21 +27,29 @@ def __init__(self, kodi_wrapper, stream_service, api_helper):
def show_main_menu_items(self):
menu_items = [
helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32080),
dict(action=actions.LISTING_AZ_TVSHOWS), False,
'DefaultMovieTitle.png',
dict(plot=self._kodi_wrapper.get_localized_string(32081))),
dict(action=actions.LISTING_AZ_TVSHOWS),
is_playable=False,
thumb='DefaultMovieTitle.png',
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32081)),
icon='DefaultMovieTitle.png'),
helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32082),
dict(action=actions.LISTING_CATEGORIES), False,
'DefaultGenre.png',
dict(plot=self._kodi_wrapper.get_localized_string(32083))),
dict(action=actions.LISTING_CATEGORIES),
is_playable=False,
thumbnail='DefaultGenre.png',
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32083)),
icon='DefaultGenre.png'),
helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32084),
dict(action=actions.LISTING_LIVE), False,
'DefaultAddonPVRClient.png',
dict(plot=self._kodi_wrapper.get_localized_string(32085))),
dict(action=actions.LISTING_LIVE),
is_playable=False,
thumbnail='DefaultAddonPVRClient.png',
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32085)),
icon='DefaultAddonPVRClient.png'),
helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32086),
dict(action=actions.LISTING_EPISODES, video_url='recent'), False,
'DefaultYear.png',
dict(plot=self._kodi_wrapper.get_localized_string(32087))),
dict(action=actions.LISTING_EPISODES, video_url='recent'),
is_playable=False,
thumbnail='DefaultYear.png',
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32087)),
icon='DefaultYear.png'),
]
self._kodi_wrapper.show_listing(menu_items)

Expand All @@ -62,17 +70,23 @@ def play(self, video):
def show_livestream_items(self):
livestream_items = [
helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32101),
{'action': actions.PLAY, 'video_url': self._EEN_LIVESTREAM},
True, self._api_helper.get_live_screenshot('een'),
dict(plot=self._kodi_wrapper.get_localized_string(32101))),
dict(action=actions.PLAY, video_url=self._EEN_LIVESTREAM),
is_playable=True,
thumbnail=self._api_helper.get_live_screenshot('een'),
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32101)),
icon='DefaultAddonPVRClient.png'),
helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32102),
{'action': actions.PLAY, 'video_url': self._CANVAS_LIVESTREAM_},
True, self._api_helper.get_live_screenshot('canvas'),
dict(plot=self._kodi_wrapper.get_localized_string(32102))),
dict(action=actions.PLAY, video_url=self._CANVAS_LIVESTREAM),
is_playable=True,
thumbnail=self._api_helper.get_live_screenshot('canvas'),
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32102)),
icon='DefaultAddonPVRClient.png'),
helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32103),
{'action': actions.PLAY, 'video_url': self._KETNET_LIVESTREAM},
True, self._api_helper.get_live_screenshot('ketnet'),
dict(plot=self._kodi_wrapper.get_localized_string(32103))),
dict(action=actions.PLAY, video_url=self._KETNET_LIVESTREAM),
is_playable=True,
thumbnail=self._api_helper.get_live_screenshot('ketnet'),
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32103)),
icon='DefaultAddonPVRClient.png'),
]
self._kodi_wrapper.show_listing(livestream_items)

Expand Down
4 changes: 2 additions & 2 deletions plugin.video.vrt.nu/vrtnutests/streamservicetests.py
Expand Up @@ -44,7 +44,7 @@ def test_get_live_stream_from_url_does_not_crash_returns_stream_and_licensekey(s
mock.open_path.return_value = False
mock.check_inputstream_adaptive.return_value = True
service = streamservice.StreamService(vrtplayer.VRTPlayer.VRT_BASE, vrtplayer.VRTPlayer.VRTNU_BASE_URL, mock, token_resolver)
video = {'video_url' : vrtplayer.VRTPlayer._CANVAS_LIVESTREAM_, 'video_id' : None, 'publication_id' : None}
video = {'video_url' : vrtplayer.VRTPlayer._CANVAS_LIVESTREAM, 'video_id' : None, 'publication_id' : None}
stream = service.get_stream(video)
self.assertTrue(stream is not None)
self.assertTrue(stream.license_key is not None)
Expand All @@ -59,7 +59,7 @@ def test_get_live_stream_from_url_does_not_crash(self):
mock.open_path.return_value = False
mock.check_inputstream_adaptive.return_value = True
service = streamservice.StreamService(vrtplayer.VRTPlayer.VRT_BASE, vrtplayer.VRTPlayer.VRTNU_BASE_URL, mock, token_resolver)
video = {'video_url' : vrtplayer.VRTPlayer._CANVAS_LIVESTREAM_, 'video_id' : None, 'publication_id' : None}
video = {'video_url' : vrtplayer.VRTPlayer._CANVAS_LIVESTREAM, 'video_id' : None, 'publication_id' : None}
stream = service.get_stream(video)
self.assertTrue(stream is not None)

Expand Down