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 My movies and My documentaries to My programs #325

Merged
merged 1 commit into from Jun 19, 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
7 changes: 7 additions & 0 deletions addon.py
Expand Up @@ -71,6 +71,13 @@ def favorites_programs():
vrtplayer.VRTPlayer(kodi).show_tvshow_menu_items(use_favorites=True)


@plugin.route('/favorites/docu')
def favorites_docu():
''' The favorites docu listing '''
from resources.lib import vrtplayer
vrtplayer.VRTPlayer(kodi).show_favorites_docu_menu_items()


@plugin.route('/favorites/recent')
@plugin.route('/favorites/recent/<page>')
def favorites_recent(page=1):
Expand Down
42 changes: 33 additions & 9 deletions resources/language/resource.language.en_gb/strings.po
Expand Up @@ -107,18 +107,34 @@ msgid "Alphabetically sorted list of My TV programs"
msgstr ""

msgctxt "#30042"
msgid "My most recent"
msgid "My movies"
msgstr ""

msgctxt "#30043"
msgid "Recently published episodes of My TV programs"
msgid "All movies available on VRT NU"
msgstr ""

msgctxt "#30044"
msgid "My soon offline"
msgid "My documentaries"
msgstr ""

msgctxt "#30045"
msgid "All [I]oneoff[/I] documentaries on VRT NU"
msgstr ""

msgctxt "#30046"
msgid "My most recent"
msgstr ""

msgctxt "#30047"
msgid "Recently published episodes of My TV programs"
msgstr ""

msgctxt "#30048"
msgid "My soon offline"
msgstr ""

msgctxt "#30049"
msgid "My video content that will soon be offline"
msgstr ""

Expand Down Expand Up @@ -279,30 +295,38 @@ msgid "When enabled, the user can follow their favourite programs and list these
msgstr ""

msgctxt "#30825"
msgid "Show fanart"
msgid "Add My movies"
msgstr ""

msgctxt "#30827"
msgid "Add My documentaries"
msgstr ""

msgctxt "#30829"
msgid "Show fanart"
msgstr ""

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

msgctxt "#30828"
msgctxt "#30832"
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 "#30829"
msgctxt "#30833"
msgid "Cache"
msgstr ""

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

msgctxt "#30832"
msgctxt "#30836"
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 "#30833"
msgctxt "#30837"
msgid "Enable local HTTP caching"
msgstr ""

Expand Down
30 changes: 27 additions & 3 deletions resources/language/resource.language.nl_nl/strings.po
Expand Up @@ -108,18 +108,34 @@ msgid "Alphabetically sorted list of My TV programs"
msgstr "Alle tv-programma's die je volgt in alfabetische volgorde"

msgctxt "#30042"
msgid "My movies"
msgstr "Mijn films"

msgctxt "#30043"
msgid "All movies available on VRT NU"
msgstr "Alle films beschikbaar op VRT NU"

msgctxt "#30044"
msgid "My documentaries"
msgstr "Mijn documentaires"

msgctxt "#30045"
msgid "All [I]oneoff[/I] documentaries on VRT NU"
msgstr "Alle [I]oneoff[/I] documentaires op VRT NU"

msgctxt "#30046"
msgid "My most recent"
msgstr "Mijn meest recent"

msgctxt "#30043"
msgctxt "#30047"
msgid "Recently published episodes of My TV programs"
msgstr "Recent gepubliceerde afleveringen van tv-programma's die je volgt"

msgctxt "#30044"
msgctxt "#30048"
msgid "My soon offline"
msgstr "Mijn binnenkort offline"

msgctxt "#30045"
msgctxt "#30049"
msgid "My video content that will soon be offline"
msgstr "Mijn tv-afleveringen die binnenkort verdwijnen"

Expand Down Expand Up @@ -271,6 +287,14 @@ msgctxt "#30824"
msgid "When enabled, the user can follow their favourite programs and list these separately. In this case the VRT NU add-on will download and update a list of your followed programs on the VRT NU website."
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 "Add My movies"
msgstr "Toon Mijn films"

msgctxt "#30827"
msgid "Add My documentaries"
msgstr "Toon Mijn documentaires"

msgctxt "#30825"
msgid "Show fanart"
msgstr "Toon fanart"
Expand Down
9 changes: 5 additions & 4 deletions resources/lib/kodiwrapper.py
Expand Up @@ -105,10 +105,11 @@ class KodiWrapper:

def __init__(self, addon):
''' Initialize the Kodi wrapper '''
self.addon = addon
self.plugin = addon['plugin']
self._handle = self.plugin.handle
self._url = self.plugin.base_url
if addon:
self.addon = addon
self.plugin = addon['plugin']
self._handle = self.plugin.handle
self._url = self.plugin.base_url
self._addon = xbmcaddon.Addon()
self._addon_id = self._addon.getAddonInfo('id')
self._max_log_level = log_levels.get(self.get_setting('max_log_level', 'Debug'), 3)
Expand Down
9 changes: 7 additions & 2 deletions resources/lib/vrtapihelper.py
Expand Up @@ -27,11 +27,13 @@ class VRTApiHelper:
def __init__(self, _kodi, _favorites):
''' Constructor for the VRTApiHelper class '''
self._kodi = _kodi
self._favorites = _favorites

self._proxies = _kodi.get_proxies()
install_opener(build_opener(ProxyHandler(self._proxies)))

self._showfanart = _kodi.get_setting('showfanart', 'true') == 'true'
self._showpermalink = _kodi.get_setting('showpermalink', 'false') == 'true'
self._favorites = _favorites
self._channel_filter = [channel.get('name') for channel in CHANNELS if _kodi.get_setting(channel.get('name'), 'true') == 'true']

def get_tvshow_items(self, category=None, channel=None, feature=None, use_favorites=False):
Expand Down Expand Up @@ -122,7 +124,7 @@ def get_latest_episode(self, program):
video = dict(video_id=episode.get('videoId'), publication_id=episode.get('publicationId'))
return video

def get_episode_items(self, program=None, season=None, category=None, feature=None, page=None, use_favorites=False, variety=None):
def get_episode_items(self, program=None, season=None, category=None, feature=None, programtype=None, page=None, use_favorites=False, variety=None):
''' Construct a list of TV show episodes TitleItems based on API query and filtered by favorites '''
titletype = None
all_items = True
Expand Down Expand Up @@ -182,6 +184,9 @@ def get_episode_items(self, program=None, season=None, category=None, feature=No
if feature:
params['facets[programTags.title]'] = feature

if programtype:
params['facets[programType]'] = programtype

api_url = self._VRTNU_SEARCH_URL + '?' + urlencode(params)
results, episodes = self._get_season_episode_data(api_url, season, all_items=all_items)

Expand Down
41 changes: 36 additions & 5 deletions resources/lib/vrtplayer.py
Expand Up @@ -19,6 +19,9 @@ def __init__(self, _kodi):
self._favorites = favorites.Favorites(_kodi)
self._apihelper = vrtapihelper.VRTApiHelper(_kodi, self._favorites)

self._addmymovies = _kodi.get_setting('addmymovies', 'true') == 'true'
self._addmydocu = _kodi.get_setting('addmydocu', 'true') == 'true'

def show_main_menu_items(self):
''' The VRT NU add-on main menu '''
self._favorites.get_favorites(ttl=60 * 60)
Expand Down Expand Up @@ -95,25 +98,53 @@ def show_favorites_menu_items(self):
is_playable=False,
art_dict=dict(thumb='DefaultMovieTitle.png', icon='DefaultMovieTitle.png', fanart='DefaultMovieTitle.png'),
video_dict=dict(plot=self._kodi.localize(30041))),
TitleItem(title=self._kodi.localize(30042), # My recent items
]

if self._addmymovies:
favorites_items.append(
TitleItem(title=self._kodi.localize(30042), # My movies
path=self._kodi.url_for('categories', category='films'),
is_playable=False,
art_dict=dict(thumb='DefaultAddonVideo.png', icon='DefaultAddonVideo.png', fanart='DefaultAddonVideo.png'),
video_dict=dict(plot=self._kodi.localize(30043))),
)

if self._addmydocu:
favorites_items.append(
TitleItem(title=self._kodi.localize(30044), # My documentaries
path=self._kodi.url_for('favorites_docu'),
is_playable=False,
art_dict=dict(thumb='DefaultMovies.png', icon='DefaultMovies.png', fanart='DefaultMovies.png'),
video_dict=dict(plot=self._kodi.localize(30045))),
)

favorites_items.extend([
TitleItem(title=self._kodi.localize(30046), # My recent items
path=self._kodi.url_for('favorites_recent'),
is_playable=False,
art_dict=dict(thumb='DefaultRecentlyAddedEpisodes.png',
icon='DefaultRecentlyAddedEpisodes.png',
fanart='DefaultRecentlyAddedEpisodes.png'),
video_dict=dict(plot=self._kodi.localize(30043))),
TitleItem(title=self._kodi.localize(30044), # My soon offline
video_dict=dict(plot=self._kodi.localize(30047))),
TitleItem(title=self._kodi.localize(30048), # My soon offline
path=self._kodi.url_for('favorites_offline'),
is_playable=False,
art_dict=dict(thumb='DefaultYear.png', icon='DefaultYear.png', fanart='DefaultYear.png'),
video_dict=dict(plot=self._kodi.localize(30045))),
]
video_dict=dict(plot=self._kodi.localize(30049))),
])

self._kodi.show_listing(favorites_items)

# Show dialog when no favorites were found
if not self._favorites.titles():
self._kodi.show_ok_dialog(heading=self._kodi.localize(30415), message=self._kodi.localize(30416))

def show_favorites_docu_menu_items(self):
''' The VRT NU add-on 'My documentaries' listing menu '''
self._favorites.get_favorites(ttl=60 * 60)
episode_items, sort, ascending, content = self._apihelper.get_episode_items(category='docu', season='allseasons', programtype='oneoff')
self._kodi.show_listing(episode_items, sort=sort, ascending=ascending, content=content)

def show_tvshow_menu_items(self, use_favorites=False):
''' The VRT NU add-on 'A-Z' listing menu '''
# My programs menus may need more up-to-date favorites
Expand Down
12 changes: 7 additions & 5 deletions resources/settings.xml
Expand Up @@ -8,11 +8,13 @@
<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="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"/>
<setting label="30825" help="30826" type="bool" id="addmymovies" default="true" enable="eq(-1,true)" subsetting="true"/>
<setting label="30827" help="30828" type="bool" id="addmydocu" default="true" enable="eq(-2,true)" subsetting="true"/>
<setting label="30829" help="30830" type="bool" id="showfanart" default="true"/>
<setting label="30831" help="30832" type="bool" id="showpermalink" default="false"/>
<setting label="30833" type="lsep"/> <!-- Cache -->
<setting label="30835" help="30836" type="bool" id="usemenucaching" default="true"/>
<setting label="30837" help="30837" type="bool" id="usehttpcaching" default="true"/>
</category>
<category label="30840"> <!-- Playback -->
<setting label="30841" type="lsep"/>
Expand Down