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

Restore the channel thumbnail to text-based thumbnail #84

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ install:
script:
- tox
- pylint plugin.video.vrt.nu/*.py
- pylint plugin.video.vrt.nu/resources/**/*.py
- pylint plugin.video.vrt.nu/resources/lib/*/*.py
- python plugin.video.vrt.nu/vrtnutests/vrtplayertests.py
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ clean:
test: unittest
@echo -e "\e[1;37m=\e[1;34m Starting tests\e[0m"
pylint $(name)/*.py
pylint $(name)/resources/**/*.py
pylint $(name)/resources/lib/*/*.py
tox -e $(ENVS)
@echo -e "\e[1;37m=\e[1;34m Tests finished successfully.\e[0m"

Expand Down
2 changes: 1 addition & 1 deletion plugin.video.vrt.nu/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def router(params_string):
vrtplayer.VRTPlayer.VRTNU_BASE_URL,
kodi_wrapper, token_resolver)
api_helper = vrtapihelper.VRTApiHelper(kodi_wrapper)
vrt_player = vrtplayer.VRTPlayer(kodi_wrapper, stream_service, api_helper)
vrt_player = vrtplayer.VRTPlayer(addon.getAddonInfo('path'), kodi_wrapper, stream_service, api_helper)
params = dict(parse_qsl(params_string))
if params:
if params['action'] == actions.LISTING_AZ_TVSHOWS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, title, url_dictionary, is_playable, thumbnail=None, video_dic
self.thumbnail = thumbnail
self.video_dictionary = video_dictionary
self.icon = icon
self.fanart = self.fanart if self.fanart else self.thumbnail
self.fanart = fanart if fanart else thumbnail


class Credentials:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# GNU General Public License v2.0 (see COPYING or https://www.gnu.org/licenses/gpl-2.0.txt)

# pylint: disable=unused-import
try:
from html import unescape
except ImportError:
Expand Down
24 changes: 16 additions & 8 deletions plugin.video.vrt.nu/resources/lib/vrtplayer/vrtplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# GNU General Public License v2.0 (see COPYING or https://www.gnu.org/licenses/gpl-2.0.txt)

import os
import requests
from bs4 import BeautifulSoup, SoupStrainer
from resources.lib.helperobjects import helperobjects
Expand All @@ -19,7 +20,8 @@ class VRTPlayer:
VRT_BASE = 'https://www.vrt.be/'
VRTNU_BASE_URL = ''.join((VRT_BASE, '/vrtnu'))

def __init__(self, kodi_wrapper, stream_service, api_helper):
def __init__(self, addon_path, kodi_wrapper, stream_service, api_helper):
self._addon_path = addon_path
self._kodi_wrapper = kodi_wrapper
self._api_helper = api_helper
self._stream_service = stream_service
Expand All @@ -29,7 +31,7 @@ def show_main_menu_items(self):
helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32080),
dict(action=actions.LISTING_AZ_TVSHOWS),
is_playable=False,
thumb='DefaultMovieTitle.png',
thumbnail='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),
Expand Down Expand Up @@ -72,28 +74,34 @@ def show_livestream_items(self):
helperobjects.TitleItem(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'),
thumbnail=self.__get_media('een.png'),
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32101)),
icon='DefaultAddonPVRClient.png'),
icon='DefaultAddonPVRClient.png',
fanart=self._api_helper.get_live_screenshot('een')),
helperobjects.TitleItem(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'),
thumbnail=self.__get_media('canvas.png'),
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32102)),
icon='DefaultAddonPVRClient.png'),
icon='DefaultAddonPVRClient.png',
fanart=self._api_helper.get_live_screenshot('canvas')),
helperobjects.TitleItem(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'),
thumbnail=self.__get_media('ketnet.png'),
video_dictionary=dict(plot=self._kodi_wrapper.get_localized_string(32103)),
icon='DefaultAddonPVRClient.png'),
icon='DefaultAddonPVRClient.png',
fanart=self._api_helper.get_live_screenshot('ketnet')),
]
self._kodi_wrapper.show_listing(livestream_items, content_type='videos')

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

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

def __get_category_menu_items(self, url, soupstrainer_parser_selector, routing_action, video_dictionary_action=None):
response = requests.get(url)
tiles = SoupStrainer('a', soupstrainer_parser_selector)
Expand Down
8 changes: 4 additions & 4 deletions plugin.video.vrt.nu/vrtnutests/vrtplayertests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ class TestVRTPlayer(unittest.TestCase):
def test_show_videos_single_episode_shows_videos(self):
mock = MagicMock()
mock.show_listing()
player = vrtplayer.VRTPlayer(mock, None, vrtapihelper.VRTApiHelper(mock))
player = vrtplayer.VRTPlayer(None, mock, None, vrtapihelper.VRTApiHelper(mock))
player.show_episodes('/vrtnu/a-z/tussen-nu-en-morgen/2018/tussen-nu-en-morgen.relevant/')
self.assertTrue(mock.show_listing.called)

def test_show_videos_single_season_shows_videos(self):
mock = MagicMock()
mock.show_listing()
player = vrtplayer.VRTPlayer(mock, None, vrtapihelper.VRTApiHelper(mock))
player = vrtplayer.VRTPlayer(None, mock, None, vrtapihelper.VRTApiHelper(mock))
player.show_episodes('/vrtnu/a-z/apocalyps--de-eerste-wereldoorlog/1/apocalyps--de-eerste-wereldoorlog-s1a3.relevant/')
self.assertTrue(mock.show_listing.called)

def test_show_videos_multiple_seasons_shows_videos(self):
mock = MagicMock()
mock.show_listing()
player = vrtplayer.VRTPlayer(mock, None, vrtapihelper.VRTApiHelper(mock))
player = vrtplayer.VRTPlayer(None, mock, None, vrtapihelper.VRTApiHelper(mock))
player.show_episodes('vrtnu/a-z/animal-babies.relevant/')
self.assertTrue(mock.show_listing.called)

def test_show_videos_specific_seasons_shows_videos(self):
mock = MagicMock()
mock.show_listing()
player = vrtplayer.VRTPlayer(mock, None, vrtapihelper.VRTApiHelper(mock))
player = vrtplayer.VRTPlayer(None, mock, None, vrtapihelper.VRTApiHelper(mock))
player.show_episodes('/vrtnu/a-z/thuis/24.lists.all-episodes.relevant/')
self.assertTrue(mock.show_listing.called)

Expand Down