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 option to enable/disable fanart #262

Merged
merged 1 commit into from
May 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -267,26 +267,30 @@ msgid "When enabled, the user can follow their favourite programs and list these
msgstr ""

msgctxt "#30825"
msgid "Show fanart"
msgstr ""

msgctxt "#30827"
msgid "Show episode permalink in plot"
msgstr ""

msgctxt "#30826"
msgctxt "#30828"
msgid "When enabled, the video description will include a permanent link that points to this episode. This is useful for quickly opening an episode or movie on a mobile device."
msgstr ""

msgctxt "#30827"
msgctxt "#30829"
msgid "Cache"
msgstr ""

msgctxt "#30829"
msgctxt "#30831"
msgid "Enable menu caching"
msgstr ""

msgctxt "#30830"
msgctxt "#30832"
msgid "When enabled, menus are being cached so they work more quickly. Only in very specific use-cases this is problematic as new episodes may not appear when they are expected."
msgstr ""

msgctxt "#30831"
msgctxt "#30833"
msgid "Enable local HTTP caching"
msgstr ""

Expand Down
12 changes: 8 additions & 4 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -260,22 +260,26 @@ msgid "When enabled, the user can follow their favourite programs and list these
msgstr "Indien actief kan de gebruiker zijn favoriete programma's volgen en apart aanroepen. Dit zorgt er wel voor dat de VRT NU add-on een lijst van favoriete programma's download en aanpast op de VRT NU website."

msgctxt "#30825"
msgid "Show fanart"
msgstr "Toon fanart"

msgctxt "#30827"
msgid "Show episode permalink in plot"
msgstr "Toon aflevering permalink in beschrijving"

msgctxt "#30826"
msgctxt "#30828"
msgid "When enabled, the video description will include a permanent link that points to this episode. This is useful for quickly opening an episode or movie on a mobile device."
msgstr "Indien actief zal de beschrijving van iedere video een permanent link bevatten die je rechtstreeks naar de VRT NU website brengt. Dit is handig om snel een aflevering of film to openen op een mobiel toestel."

msgctxt "#30827"
msgctxt "#30829"
msgid "Cache"
msgstr "Cache"

msgctxt "#30829"
msgctxt "#30831"
msgid "Enable menu caching"
msgstr "Gebruik menu caching"

msgctxt "#30831"
msgctxt "#30833"
msgid "Enable local HTTP caching"
msgstr "Gebruik local HTTP caching"

Expand Down
6 changes: 5 additions & 1 deletion resources/lib/vrtplayer/tvguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, _kodi):
self._kodi = _kodi
self._proxies = _kodi.get_proxies()
install_opener(build_opener(ProxyHandler(self._proxies)))
self._showfanart = _kodi.get_setting('showfanart') == 'true'

def show_tvguide(self, params):
date = params.get('date')
Expand Down Expand Up @@ -165,7 +166,10 @@ def show_episodes(self, date, channel):
metadata.plot = '[B]%s[/B]\n%s\n%s - %s\n[I]%s[/I]' % (title, datelong, start, end, channel.get('label'))
metadata.brands = [channel.get('studio')]
metadata.mediatype = 'episode'
thumb = episode.get('image', 'DefaultAddonVideo.png')
if self._showfanart:
thumb = episode.get('image', 'DefaultAddonVideo.png')
else:
thumb = 'DefaultAddonVideo.png'
metadata.icon = thumb
if url:
video_url = statichelper.add_https_method(url)
Expand Down
27 changes: 21 additions & 6 deletions resources/lib/vrtplayer/vrtapihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self, _kodi, _favorites):
self._kodi = _kodi
self._proxies = _kodi.get_proxies()
install_opener(build_opener(ProxyHandler(self._proxies)))
self._showfanart = _kodi.get_setting('showfanart') == 'true'
self._showpermalink = _kodi.get_setting('showpermalink') == 'true'
self._favorites = _favorites

Expand Down Expand Up @@ -69,7 +70,10 @@ def _map_to_tvshow_items(self, tvshows, filtered=False):
# NOTE: This adds episode_count to label, would be better as metadata
# title = '%s [LIGHT][COLOR yellow]%s[/COLOR][/LIGHT]' % (tvshow.get('title', '???'), tvshow.get('episode_count', '?'))
label = tvshow.get('title', '???')
thumbnail = statichelper.add_https_method(tvshow.get('thumbnail', 'DefaultAddonVideo.png'))
if self._showfanart:
thumbnail = statichelper.add_https_method(tvshow.get('thumbnail', 'DefaultAddonVideo.png'))
else:
thumbnail = 'DefaultAddonVideo.png'
program_path = statichelper.unique_path(tvshow.get('targetUrl'))
if self._favorites.is_activated():
program = tvshow.get('title').encode('utf-8')
Expand Down Expand Up @@ -275,8 +279,12 @@ def _map_to_episode_items(self, episodes, titletype=None, season_key=None, filte
else:
context_menu = []

thumb = statichelper.add_https_method(episode.get('videoThumbnailUrl', 'DefaultAddonVideo.png'))
fanart = statichelper.add_https_method(episode.get('programImageUrl', thumb))
if self._showfanart:
thumb = statichelper.add_https_method(episode.get('videoThumbnailUrl', 'DefaultAddonVideo.png'))
fanart = statichelper.add_https_method(episode.get('programImageUrl', thumb))
else:
thumb = 'DefaultAddonVideo.png'
fanart = 'DefaultAddonVideo.png'
video_url = statichelper.add_https_method(episode.get('url'))
label, sort, ascending = self._make_label(episode, titletype, options=display_options)
metadata.title = label
Expand All @@ -299,7 +307,10 @@ def _map_to_season_items(self, api_url, seasons, episodes):

episode = random.choice(episodes)
program_type = episode.get('programType')
fanart = statichelper.add_https_method(episode.get('programImageUrl', 'DefaultSets.png'))
if self._showfanart:
fanart = statichelper.add_https_method(episode.get('programImageUrl', 'DefaultSets.png'))
else:
fanart = 'DefaultSets.png'

metadata = metadatacreator.MetadataCreator()
metadata.tvshowtitle = episode.get('program')
Expand Down Expand Up @@ -340,8 +351,12 @@ def _map_to_season_items(self, api_url, seasons, episodes):
episode = random.choice([e for e in episodes if e.get('seasonName') == season_key])
except IndexError:
episode = episodes[0]
fanart = statichelper.add_https_method(episode.get('programImageUrl', 'DefaultSets.png'))
thumbnail = statichelper.add_https_method(episode.get('videoThumbnailUrl', fanart))
if self._showfanart:
fanart = statichelper.add_https_method(episode.get('programImageUrl', 'DefaultSets.png'))
thumbnail = statichelper.add_https_method(episode.get('videoThumbnailUrl', fanart))
else:
fanart = 'DefaultSets.png'
thumbnail = 'DefaultSets.png'
label = '%s %s' % (self._kodi.localize(30094), season_key)
params = {'facets[seasonTitle]': season_key}
path = api_url + '&' + urlencode(params)
Expand Down
18 changes: 12 additions & 6 deletions resources/lib/vrtplayer/vrtplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, _kodi, _favorites, _apihelper):
self._apihelper = _apihelper
self._proxies = _kodi.get_proxies()
install_opener(build_opener(ProxyHandler(self._proxies)))
self._showfanart = _kodi.get_setting('showfanart') == 'true'

def show_main_menu_items(self):
main_items = []
Expand Down Expand Up @@ -150,7 +151,8 @@ def show_channels(self, action=actions.PLAY, channels=None):
label = self._kodi.localize(30101).format(**channel)
is_playable = True
if channel.get('name') in ['een', 'canvas', 'ketnet']:
fanart = self._apihelper.get_live_screenshot(channel.get('name'))
if self._showfanart:
fanart = self._apihelper.get_live_screenshot(channel.get('name', fanart))
plot = '%s\n\n%s' % (self._kodi.localize(30102).format(**channel), _tvguide.live_description(channel.get('name')))
else:
plot = self._kodi.localize(30102).format(**channel)
Expand Down Expand Up @@ -276,7 +278,10 @@ def get_category_menu_items(self):

category_items = []
for category in categories:
thumbnail = category.get('thumbnail', 'DefaultGenre.png')
if self._showfanart:
thumbnail = category.get('thumbnail', 'DefaultGenre.png')
else:
thumbnail = 'DefaultGenre.png'
category_items.append(TitleItem(
title=category.get('name'),
url_dict=dict(action=actions.LISTING_CATEGORY_TVSHOWS, category=category.get('id')),
Expand All @@ -303,10 +308,11 @@ def get_categories(self, proxies=None):

return categories

@staticmethod
def get_category_thumbnail(element):
raw_thumbnail = element.find(class_='media').get('data-responsive-image', 'DefaultGenre.png')
return statichelper.add_https_method(raw_thumbnail)
def get_category_thumbnail(self, element):
if self._showfanart:
raw_thumbnail = element.find(class_='media').get('data-responsive-image', 'DefaultGenre.png')
return statichelper.add_https_method(raw_thumbnail)
return 'DefaultGenre.png'

@staticmethod
def get_category_title(element):
Expand Down
9 changes: 5 additions & 4 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<category label="30820"> <!-- Interface -->
<setting label="30821" type="lsep"/> <!-- Features -->
<setting label="30823" help="30824" type="bool" id="usefavorites" default="true"/>
<setting label="30825" help="30826" type="bool" id="showpermalink" default="false"/>
<setting label="30827" type="lsep"/> <!-- Cache -->
<setting label="30829" help="30830" type="bool" id="usemenucaching" default="true"/>
<setting label="30831" help="30832" type="bool" id="usehttpcaching" default="true"/>
<setting label="30825" help="30826" type="bool" id="showfanart" default="true"/>
<setting label="30827" help="30828" type="bool" id="showpermalink" default="false"/>
<setting label="30829" type="lsep"/> <!-- Cache -->
<setting label="30831" help="30832" type="bool" id="usemenucaching" default="true"/>
<setting label="30833" help="30834" type="bool" id="usehttpcaching" default="true"/>
</category>
<category label="30840"> <!-- Playback -->
<setting label="30841" type="lsep"/>
Expand Down