Skip to content

Commit

Permalink
Add icon support
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers committed May 2, 2019
1 parent bf3c63c commit f01c712
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 19 deletions.
1 change: 1 addition & 0 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
provider-name="Martijn Moreel">

<requires>
<import addon="resource.images.studios.white" version="0.0.21"/>
<!-- import addon="inputstream.adaptive" version="2.0.19"/ -->
<import addon="script.module.beautifulsoup4" version="4.5.3"/>
<import addon="script.module.dateutil" version="2.6.0"/>
Expand Down
11 changes: 9 additions & 2 deletions resources/lib/kodiwrappers/kodiwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ def __init__(self, handle, url, addon):
self._addon = addon
self._addon_id = addon.getAddonInfo('id')

def show_listing(self, list_items, sort='unsorted', ascending=True, content_type='episodes', cache=True):
def show_listing(self, list_items, sort='unsorted', ascending=True, content_type=None, cache=True):
listing = []

xbmcplugin.setContent(self._handle, content=content_type)
if content_type:
xbmcplugin.setContent(self._handle, content=content_type)

# FIXME: Since there is no way to influence descending order, we force it here
if not ascending:
Expand Down Expand Up @@ -198,6 +199,12 @@ def get_proxies(self):
def has_inputstream_adaptive_installed(self):
return xbmc.getCondVisibility('System.HasAddon("{0}")'.format('inputstream.adaptive')) == 1

def has_white_icons(self):
return xbmc.getCondVisibility('System.HasAddon("resource.images.studios.white")') == 1

def has_coloured_icons(self):
return xbmc.getCondVisibility('System.HasAddon("resource.images.studios.coloured")') == 1

def can_play_drm(self):
kodi_version = int(xbmc.getInfoLabel('System.BuildVersion').split('.')[0])
return kodi_version > 17
Expand Down
20 changes: 12 additions & 8 deletions resources/lib/vrtplayer/tvguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from datetime import datetime, timedelta
import dateutil.parser
import dateutil.tz
import os
import requests

from resources.lib.helperobjects import helperobjects
Expand Down Expand Up @@ -53,24 +52,32 @@ def show_tvguide(self, params):
art_dict=dict(thumb='DefaultYear.png', icon='DefaultYear.png', fanart='DefaultYear.png'),
video_dict=dict(plot=day.strftime(self._kodi_wrapper.get_localized_datelong()))),
)
self._kodi_wrapper.show_listing(date_items, sort='unsorted', content_type='files')
self._kodi_wrapper.show_listing(date_items, content_type='files')

elif not channel:
dateobj = dateutil.parser.parse(date)
datelong = dateobj.strftime(self._kodi_wrapper.get_localized_datelong())

fanart_path = 'resource://resource.images.studios.white/%(studio)s.png'
icon_path = 'resource://resource.images.studios.white/%(studio)s.png'
# NOTE: Wait for resource.images.studios.coloured v0.16 to be released
# icon_path = 'resource://resource.images.studios.coloured/%(studio)s.png'

channel_items = []
for channel in ('een', 'canvas', 'ketnet'):
icon = icon_path % CHANNELS[channel]
fanart = fanart_path % CHANNELS[channel]
plot = self._kodi_wrapper.get_localized_string(32301) % CHANNELS[channel]['name'] + '\n' + datelong
channel_items.append(
helperobjects.TitleItem(
title=CHANNELS[channel]['name'],
url_dict=dict(action=actions.LISTING_TVGUIDE, date=date, channel=channel),
is_playable=False,
art_dict=dict(thumb=self.__get_media(channel + '.png'), icon='DefaultAddonPVRClient.png', fanart='DefaultAddonPVRClient.png'),
art_dict=dict(thumb=icon, icon=icon, fanart=fanart),
video_dict=dict(plot=plot, studio=CHANNELS[channel]['studio']),
),
)
self._kodi_wrapper.show_listing(channel_items, content_type='files')
self._kodi_wrapper.show_listing(channel_items)

else:
now = datetime.now(dateutil.tz.tzlocal())
Expand Down Expand Up @@ -119,7 +126,4 @@ def show_tvguide(self, params):
art_dict=dict(thumb=thumb, icon='DefaultAddonVideo.png', fanart=thumb),
video_dict=metadata.get_video_dict(),
))
self._kodi_wrapper.show_listing(episode_items, sort='unsorted', content_type='episodes', cache=False)

def __get_media(self, file_name):
return os.path.join(self._addon_path, 'resources', 'media', file_name)
self._kodi_wrapper.show_listing(episode_items, content_type='episodes', cache=False)
21 changes: 12 additions & 9 deletions resources/lib/vrtplayer/vrtplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def show_main_menu_items(self):
art_dict=dict(thumb='DefaultAddonTvInfo.png', icon='DefaultAddonTvInfo.png', fanart='DefaultAddonTvInfo.png'),
video_dict=dict(plot=self._kodi_wrapper.get_localized_string(32089))),
]
self._kodi_wrapper.show_listing(main_items, sort='unsorted', content_type='files')
self._kodi_wrapper.show_listing(main_items)

def show_tvshow_menu_items(self, path):
tvshow_items = self._api_helper.get_tvshow_items(path)
Expand All @@ -87,15 +87,21 @@ def show_category_menu_items(self):
self._kodi_wrapper.show_listing(category_items, sort='label', content_type='files')

def show_livestream_items(self):

fanart_path = 'resource://resource.images.studios.white/%(studio)s.png'
icon_path = 'resource://resource.images.studios.white/%(studio)s.png'
# NOTE: Wait for resource.images.studios.coloured v0.16 to be released
# icon_path = 'resource://resource.images.studios.coloured/%(studio)s.png'

livestream_items = []
for channel in ['een', 'canvas', 'ketnet', 'sporza', 'stubru', 'mnm']:

icon = icon_path % CHANNELS[channel]
if channel in ['een', 'canvas', 'ketnet']:
thumbnail = self.__get_media(channel + '.png')
fanart = self._api_helper.get_live_screenshot(channel)
plot = self._kodi_wrapper.get_localized_string(32201) + '\n' + self._kodi_wrapper.get_localized_string(32102) % CHANNELS[channel].get('name')
else:
thumbnail = 'DefaultAddonMusic.png'
fanart = 'DefaultAddonPVRClient.png'
fanart = fanart_path % CHANNELS[channel]
plot = self._kodi_wrapper.get_localized_string(32102) % CHANNELS[channel].get('name')

url_dict = dict(action=actions.PLAY)
Expand All @@ -108,7 +114,7 @@ def show_livestream_items(self):
title=self._kodi_wrapper.get_localized_string(32101) % CHANNELS[channel].get('name'),
url_dict=url_dict,
is_playable=True,
art_dict=dict(thumb=thumbnail, icon='DefaultAddonPVRClient.png', fanart=fanart),
art_dict=dict(thumb=icon, icon=icon, fanart=fanart),
video_dict=dict(
title=self._kodi_wrapper.get_localized_string(32101) % CHANNELS[channel].get('name'),
plot=plot,
Expand All @@ -117,7 +123,7 @@ def show_livestream_items(self):
),
))

self._kodi_wrapper.show_listing(livestream_items, sort='unsorted', content_type='videos', cache=False)
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)
Expand All @@ -128,9 +134,6 @@ def play(self, params):
if stream is not None:
self._kodi_wrapper.play(stream)

def __get_media(self, file_name):
return os.path.join(self._addon_path, 'resources', 'media', file_name)

def __get_category_menu_items(self):
try:
categories = get_categories(self._proxies)
Expand Down
Binary file removed resources/media/canvas.png
Binary file not shown.
Binary file removed resources/media/een.png
Binary file not shown.
Binary file removed resources/media/ketnet.png
Binary file not shown.
Binary file removed resources/media/sporza.png
Binary file not shown.

0 comments on commit f01c712

Please sign in to comment.