Skip to content

Commit

Permalink
Add "My programs" menu
Browse files Browse the repository at this point in the history
This PR adds a way of tracking the programs you follow.
- Add a context menu to programs or episodes with either "Follow" or "Unfollow"
- Download and cache favorites from VRT NU
- Add an A-Z listing of followed programs
- Add a Recent listing of followed programs
- Add invisible setting 'usefavorites' to disable "My programs" (for unit tests)
- Disable brand filter in "My programs" recent listing (should be configurable really)
  • Loading branch information
dagwieers committed May 14, 2019
1 parent ca292d6 commit ce5c716
Show file tree
Hide file tree
Showing 15 changed files with 406 additions and 30 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ unit:
PYTHONPATH=$(pwd) python test/apihelpertests.py
PYTHONPATH=$(pwd) python test/tvguidetests.py
PYTHONPATH=$(pwd) python test/searchtests.py
PYTHONPATH=$(pwd) python test/favoritestests.py
@echo -e "$(white)=$(blue) Unit tests finished successfully.$(reset)"

zip: test
Expand Down
21 changes: 19 additions & 2 deletions addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ def router(params_string):
_tvguide = tvguide.TVGuide(_kodiwrapper)
_tvguide.show_tvguide(params)
return
if action == actions.FOLLOW:
from resources.lib.vrtplayer import favorites
_favorites = favorites.Favorites(_kodiwrapper)
_favorites.follow(program=params.get('program'), path=params.get('path'))
return
if action == actions.UNFOLLOW:
from resources.lib.vrtplayer import favorites
_favorites = favorites.Favorites(_kodiwrapper)
_favorites.unfollow(program=params.get('program'), path=params.get('path'))
return
if action == actions.REFRESH_FAVORITES:
from resources.lib.vrtplayer import favorites
_favorites = favorites.Favorites(_kodiwrapper)
_favorites.update_favorites()
return

from resources.lib.vrtplayer import vrtapihelper, vrtplayer
_apihelper = vrtapihelper.VRTApiHelper(_kodiwrapper)
Expand All @@ -47,21 +62,23 @@ def router(params_string):
if action == actions.PLAY:
_vrtplayer.play(params)
elif action == actions.LISTING_AZ_TVSHOWS:
_vrtplayer.show_tvshow_menu_items()
_vrtplayer.show_tvshow_menu_items(filtered=params.get('filtered'))
elif action == actions.LISTING_CATEGORIES:
_vrtplayer.show_category_menu_items()
elif action == actions.LISTING_CATEGORY_TVSHOWS:
_vrtplayer.show_tvshow_menu_items(category=params.get('category'))
elif action == actions.LISTING_CHANNELS:
_vrtplayer.show_channels_menu_items(channel=params.get('channel'))
elif action == actions.LISTING_FAVORITES:
_vrtplayer.show_favorites_menu_items()
elif action == actions.LISTING_LIVE:
_vrtplayer.show_livestream_items()
elif action == actions.LISTING_EPISODES:
_vrtplayer.show_episodes(path=params.get('video_url'))
elif action == actions.LISTING_ALL_EPISODES:
_vrtplayer.show_all_episodes(path=params.get('video_url'))
elif action == actions.LISTING_RECENT:
_vrtplayer.show_recent(page=params.get('page', 1))
_vrtplayer.show_recent(page=params.get('page', 1), filtered=params.get('filtered'))
elif action == actions.SEARCH:
_vrtplayer.search(search_string=params.get('query'), page=params.get('page', 1))
else:
Expand Down
1 change: 1 addition & 0 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<provides>video</provides>
</extension>
<extension point="xbmc.service" library="service.py"/>

<extension point="xbmc.addon.metadata">
<summary lang="en_GB">Watch videos from VRT NU</summary>
<description lang="en_GB">
Expand Down
49 changes: 48 additions & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ msgid "Interface"
msgstr "Interface"

msgctxt "#30001"
msgid "Enable My programs"
msgstr "Enable My programs"

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

msgctxt "#30002"
msgctxt "#30003"
msgid "Enable menu caching"
msgstr "Enable menu caching"

Expand Down Expand Up @@ -75,6 +79,10 @@ msgctxt "#30042"
msgid "Install Widevine (for DRM content)"
msgstr "Install Widevine (for DRM content)"

msgctxt "#30047"
msgid "Refresh favorites"
msgstr "Refresh favorites"

msgctxt "#30048"
msgid "Clear VRT cookies"
msgstr "Clear VRT cookies"
Expand Down Expand Up @@ -115,6 +123,14 @@ msgctxt "#30061"
msgid "Using a SOCKS proxy requires the PySocks library (script.module.pysocks) installed."
msgstr "Using a SOCKS proxy requires the PySocks library (script.module.pysocks) installed."

msgctxt "#30078"
msgid "My programs"
msgstr "My programs"

msgctxt "#30079"
msgid "Browse only the programs you follow"
msgstr "Browse only the programs you follow"

msgctxt "#30080"
msgid "A-Z"
msgstr "A-Z"
Expand Down Expand Up @@ -251,3 +267,34 @@ msgctxt "#30334"
msgid "In 2 days"
msgstr "In 2 days"

msgctxt "#30411"
msgid "Follow"
msgstr "Follow"

msgctxt "#30412"
msgid "Unfollow"
msgstr "Unfollow"

msgctxt "#30415"
msgid "No followed programs found"
msgstr "No followed programs found"

msgctxt "#30416"
msgid "We could not find any programs that were followed.\n\nEither right-click on a program or an episode to follow a program, or follow a program on the VRT NU website."
msgstr "We could not find any programs that were followed.\n\nEither right-click on a program or an episode to follow a program, or follow a program on the VRT NU website."

msgctxt "#30420"
msgid "My A-Z"
msgstr "My A-Z"

msgctxt "#30421"
msgid "Alphabetically sorted list of My TV programs"
msgstr "Alphabetically sorted list of My TV programs"

msgctxt "#30422"
msgid "My recent items"
msgstr "My recent items"

msgctxt "#30423"
msgid "Recently published episodes of My TV programs"
msgstr "Recently published episodes of My TV programs"
50 changes: 49 additions & 1 deletion resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ msgid "Interface"
msgstr "Interface"

msgctxt "#30001"
msgid "Enable My programs"
msgstr "Toon Mijn TV programma's"

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

msgctxt "#30002"
msgctxt "#30003"
msgid "Enable menu caching"
msgstr "Gebruik menu caching"

Expand Down Expand Up @@ -84,6 +88,10 @@ msgctxt "#30042"
msgid "Install Widevine (for DRM content)"
msgstr "Installeer Widevine (voor DRM content)"

msgctxt "#30047"
msgid "Refresh favorites"
msgstr "Ververs gevolgde programma's"

msgctxt "#30048"
msgid "Clear VRT cookies"
msgstr "Verwijder VRT cookies"
Expand Down Expand Up @@ -124,6 +132,14 @@ msgctxt "#30061"
msgid "Using a SOCKS proxy requires the PySocks library (script.module.pysocks) installed."
msgstr "Het gebruik van SOCKS proxies vereist dat de PySocks library (script.module.pysocks) geïnstalleerd is."

msgctxt "#30078"
msgid "My programs"
msgstr "Mijn TV programma's"

msgctxt "#30079"
msgid "Browse only the programs you follow"
msgstr "Bekijk enkel de programma's die je volgt"

msgctxt "#30080"
msgid "A-Z"
msgstr "A-Z"
Expand Down Expand Up @@ -259,3 +275,35 @@ msgstr "Morgen"
msgctxt "#30334"
msgid "In 2 days"
msgstr "Overmorgen"

msgctxt "#30411"
msgid "Follow"
msgstr "Volg"

msgctxt "#30412"
msgid "Unfollow"
msgstr "Vergeet"

msgctxt "#30415"
msgid "No followed programs found"
msgstr "Geen programma's worden gevolgd"

msgctxt "#30416"
msgid "We could not find any programs that were followed.\n\nEither right-click on a program or an episode to follow a program, or follow a program on the VRT NU website."
msgstr "We konden geen programma's vonden die je volgt.\n\nJe kan een programma volgen door rechts te klikken op een programma of aflevering, of om ze op de VRT NU website to volgen."

msgctxt "#30420"
msgid "My A-Z"
msgstr "Mijn TV programma's"

msgctxt "#30421"
msgid "Alphabetically sorted list of My TV programs"
msgstr "Alle TV-programma's die je volgt in alfabetische volgorde"

msgctxt "#30422"
msgid "My recent items"
msgstr "Mijn recente afleveringen"

msgctxt "#30423"
msgid "Recently published episodes of My TV programs"
msgstr "Recent gepubliceerde afleveringen van TV-programma's die je volgt"
3 changes: 2 additions & 1 deletion resources/lib/helperobjects/helperobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

class TitleItem:

def __init__(self, title, url_dict, is_playable, art_dict=None, video_dict=None):
def __init__(self, title, url_dict, is_playable, art_dict=None, video_dict=None, context_menu=None):
self.title = title
self.url_dict = url_dict
self.is_playable = is_playable
self.art_dict = art_dict
self.video_dict = video_dict
self.context_menu = context_menu


class Credentials:
Expand Down
18 changes: 17 additions & 1 deletion resources/lib/kodiwrappers/kodiwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ def show_listing(self, list_items, sort='unsorted', ascending=True, content=None
if title_item.video_dict:
list_item.setInfo(type='video', infoLabels=title_item.video_dict)

if title_item.context_menu:
list_item.addContextMenuItems(title_item.context_menu)

listing.append((url, list_item, not title_item.is_playable))

ok = xbmcplugin.addDirectoryItems(self._handle, listing, len(listing))
Expand Down Expand Up @@ -199,7 +202,13 @@ def get_search_string(self):

def show_ok_dialog(self, title, message):
import xbmcgui
xbmcgui.Dialog().ok(self._addon.getAddonInfo('name'), title, message)
if not title:
title = self._addon.getAddonInfo('name')
xbmcgui.Dialog().ok(title, message)

def show_notification(self, message, time=4000):
import xbmcgui
xbmcgui.Dialog().notification(self._addon.getAddonInfo('name'), message, xbmcgui.NOTIFICATION_INFO, time)

def set_locale(self):
import locale
Expand Down Expand Up @@ -334,10 +343,17 @@ def open_file(self, path, flags='r'):
yield f
f.close()

def stat_file(self, path):
import xbmcvfs
return xbmcvfs.Stat(path)

def delete_file(self, path):
import xbmcvfs
return xbmcvfs.delete(path)

def container_refresh(self):
xbmc.executebuiltin('Container.Refresh')

def log_access(self, url, query_string, log_level='Verbose'):
''' Log addon access '''
if log_levels.get(log_level, 0) <= self._max_log_level:
Expand Down
4 changes: 4 additions & 0 deletions resources/lib/vrtplayer/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
from __future__ import absolute_import, division, unicode_literals

CLEAR_COOKIES = 'clearcookies'
FOLLOW = 'follow'
LISTING_ALL_EPISODES = 'listingallepisodes'
LISTING_AZ_TVSHOWS = 'listingaztvshows'
LISTING_CATEGORIES = 'listingcategories'
LISTING_CATEGORY_TVSHOWS = 'listingcategorytvshows'
LISTING_CHANNELS = 'listingchannels'
LISTING_EPISODES = 'listingepisodes'
LISTING_FAVORITES = 'favorites'
LISTING_LIVE = 'listinglive'
LISTING_RECENT = 'listingrecent'
LISTING_TVGUIDE = 'listingtvguide'
PLAY = 'play'
REFRESH_FAVORITES = 'refreshfavorites'
SEARCH = 'search'
UNFOLLOW = 'unfollow'
Loading

0 comments on commit ce5c716

Please sign in to comment.