Skip to content

Commit

Permalink
Update API (#132)
Browse files Browse the repository at this point in the history
* Update API
* Use ADDON_PROFILE during Travis tests
* Fix continue watching episode details
* Don't depend on kodi-addon-checker anymore
  • Loading branch information
michaelarnauts committed Jan 24, 2020
1 parent 8477c04 commit 8386dfc
Show file tree
Hide file tree
Showing 25 changed files with 252 additions and 143 deletions.
24 changes: 13 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
language: python

python:
- '2.7'
- '3.6'
- '3.7'
- '2.7'
- '3.5'
- '3.6'
- '3.7'
- '3.8'

sudo: false
os: linux

env:
PYTHONPATH: :test
PYTHONIOENCODING: utf-8

install:
- pip install -r requirements.txt
- pip install -r requirements.txt

script:
- make check-pylint
- make check-tox
- make check-translations
#- make check-addon
- make test
- make check-pylint
- make check-tox
- make check-translations
# - make check-addon
- make test

after_success:
- codecov
- codecov
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
## Features

The following features are supported:
* User Profiles with access to the specified catalog (VTM GO or VTM GO Kids)
* Watch live TV (VTM, Q2, Vitaya, CAZ, VTM Kids, VTM Kids Jr & QMusic)
* Watch on-demand content (movies and series)
* Browse the VTM GO recommendations and "My List"
* Browse a TV Guide
* Search the catalogue
* Browse the Kids zone
* Watch YouTube content from some of the DPG Media channels

## Installation
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
codecov
git+git://github.com/emilsvennesson/script.module.inputstreamhelper.git@master#egg=inputstreamhelper
kodi-addon-checker
polib
pylint
python-dateutil
Expand Down
12 changes: 2 additions & 10 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ msgid "Search the VTM GO catalogue"
msgstr ""

msgctxt "#30011"
msgid "Kids zone"
msgid "Switch Profile ([B]{profile}[/B])"
msgstr ""

msgctxt "#30012"
msgid "Go to the Kids zone"
msgid "Select a different profile to use"
msgstr ""

msgctxt "#30013"
Expand Down Expand Up @@ -323,14 +323,6 @@ msgctxt "#30823"
msgid "Show My List"
msgstr ""

msgctxt "#30824"
msgid "Show Kids zone"
msgstr ""

msgctxt "#30825"
msgid "Force Kids zone"
msgstr ""

msgctxt "#30826"
msgid "Show Continue watching"
msgstr ""
Expand Down
16 changes: 4 additions & 12 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ msgid "Search the VTM GO catalogue"
msgstr "Doorzoek de VTM catalogus"

msgctxt "#30011"
msgid "Kids zone"
msgstr "Kids zone"
msgid "Switch Profile ([B]{profile}[/B])"
msgstr "Verwissel profiel ([B]{profile}[/B])"

msgctxt "#30012"
msgid "Go to the Kids zone"
msgstr "Ga naar de Kids zone"
msgid "Select a different profile to use"
msgstr "Selecteer een ander profiel om te gebruiken"

msgctxt "#30013"
msgid "TV guide"
Expand Down Expand Up @@ -323,14 +323,6 @@ msgctxt "#30823"
msgid "Show My List"
msgstr "Toon 'Mijn lijst' menu"

msgctxt "#30824"
msgid "Show Kids zone"
msgstr "Toon 'Kids zone' menu"

msgctxt "#30825"
msgid "Force Kids zone"
msgstr "Forceer kids zone"

msgctxt "#30826"
msgid "Show Continue watching"
msgstr "Toon 'Verder kijken' menu"
Expand Down
14 changes: 0 additions & 14 deletions resources/lib/kodiwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,12 @@ def show_listing(self, title_items, category=None, sort=None, content=None, cach
if category:
if not content:
category_label = self._addon_name + ' / '
if self.kids_mode():
category_label += 'KIDS / '
if isinstance(category, int):
category_label += self.localize(category)
else:
category_label += category
elif not content:
category_label = self._addon_name
if self.kids_mode():
category_label += ' / KIDS'

xbmcplugin.setPluginCategory(handle=self._handle, category=category_label)

Expand Down Expand Up @@ -548,13 +544,3 @@ def log(self, message, log_level=LOG_INFO, **kwargs):
message = string.Formatter().vformat(message, (), SafeDict(**kwargs))
message = '[{addon}] {message}'.format(addon=self._addon_id, message=message)
xbmc.log(msg=from_unicode(message), level=log_level)

def kids_mode(self):
""" Returns if kids zone is active """
if self.get_setting_as_bool('interface_force_kids_zone'):
return True

if self.routing and 'True' in self.routing.args.get('kids', []):
return True

return None
10 changes: 4 additions & 6 deletions resources/lib/modules/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Catalog:

def __init__(self, kodi):
""" Initialise object
:type kodi: KodiWrapper
:type kodi: resources.lib.kodiwrapper.KodiWrapper
"""
self._kodi = kodi
self._vtm_go = VtmGo(self._kodi)
Expand All @@ -32,7 +32,7 @@ def show_catalog(self):
for cat in categories:
listing.append(
TitleItem(title=cat.title,
path=self._kodi.url_for('show_catalog_category', kids=self._kodi.kids_mode(), category=cat.category_id),
path=self._kodi.url_for('show_catalog_category', category=cat.category_id),
info_dict={
'plot': '[B]{category}[/B]'.format(category=cat.title),
})
Expand Down Expand Up @@ -173,7 +173,7 @@ def show_recommendations(self):
for cat in recommendations:
listing.append(
TitleItem(title=cat.title,
path=self._kodi.url_for('show_recommendations_category', kids=self._kodi.kids_mode(), category=cat.category_id),
path=self._kodi.url_for('show_recommendations_category', category=cat.category_id),
info_dict={
'plot': '[B]{category}[/B]'.format(category=cat.title),
})
Expand Down Expand Up @@ -250,10 +250,8 @@ def show_continuewatching(self):
titleitem = self._menu.generate_titleitem(item, progress=True)

# Add Program Name to title since this list contains episodes from multiple programs
title = '%s - %dx%02d - %s' % (
title = '%s - %s' % (
titleitem.info_dict.get('tvshowtitle'),
titleitem.info_dict.get('season'),
titleitem.info_dict.get('episode'),
titleitem.info_dict.get('title'))
titleitem.info_dict['title'] = title
listing.append(titleitem)
Expand Down
5 changes: 3 additions & 2 deletions resources/lib/modules/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ class Channels:

def __init__(self, kodi):
""" Initialise object
:type kodi: KodiWrapper
:type kodi: resources.lib.kodiwrapper.KodiWrapper
"""
self._kodi = kodi
self._vtm_go = VtmGo(self._kodi)
self._menu = Menu(self._kodi)

def show_channels(self):
""" Shows TV channels """
kids = self._kodi.kids_mode()
product = self._vtm_go.get_product()
kids = (product == 'VTM_GO_KIDS')

# Fetch EPG from API
channel_infos = self._vtm_go.get_live_channels()
Expand Down
57 changes: 28 additions & 29 deletions resources/lib/modules/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ class Menu:

def __init__(self, kodi):
""" Initialise object
:type kodi: KodiWrapper
:type kodi: resources.lib.kodiwrapper.KodiWrapper
"""
self._kodi = kodi
self._vtm_go = VtmGo(self._kodi)

def show_mainmenu(self):
""" Show the main menu """
kids = self._kodi.kids_mode()

listing = []
listing.append(
TitleItem(title=self._kodi.localize(30001), # A-Z
path=self._kodi.url_for('show_catalog_all', kids=kids),
path=self._kodi.url_for('show_catalog_all'),
art_dict=dict(
icon='DefaultMovieTitle.png'
),
Expand All @@ -35,7 +33,7 @@ def show_mainmenu(self):
)))
listing.append(
TitleItem(title=self._kodi.localize(30003), # Catalogue
path=self._kodi.url_for('show_catalog', kids=kids),
path=self._kodi.url_for('show_catalog'),
art_dict=dict(
icon='DefaultGenre.png'
),
Expand All @@ -44,7 +42,7 @@ def show_mainmenu(self):
)))
listing.append(
TitleItem(title=self._kodi.localize(30007), # TV Channels
path=self._kodi.url_for('show_channels', kids=kids),
path=self._kodi.url_for('show_channels'),
art_dict=dict(
icon='DefaultAddonPVRClient.png'
),
Expand All @@ -55,7 +53,7 @@ def show_mainmenu(self):
if self._kodi.get_setting_as_bool('interface_show_recommendations'):
listing.append(
TitleItem(title=self._kodi.localize(30015), # Recommendations
path=self._kodi.url_for('show_recommendations', kids=kids),
path=self._kodi.url_for('show_recommendations'),
art_dict={
'icon': 'DefaultFavourites.png'
},
Expand All @@ -66,7 +64,7 @@ def show_mainmenu(self):
if self._kodi.get_setting_as_bool('interface_show_mylist'):
listing.append(
TitleItem(title=self._kodi.localize(30017), # My List
path=self._kodi.url_for('show_mylist', kids=kids),
path=self._kodi.url_for('show_mylist'),
art_dict={
'icon': 'DefaultPlaylist.png'
},
Expand All @@ -77,7 +75,7 @@ def show_mainmenu(self):
if self._kodi.get_setting_as_bool('interface_show_continuewatching'):
listing.append(
TitleItem(title=self._kodi.localize(30019), # Continue watching
path=self._kodi.url_for('show_continuewatching', kids=kids),
path=self._kodi.url_for('show_continuewatching'),
art_dict={
'icon': 'DefaultInProgressShows.png'
},
Expand All @@ -87,24 +85,23 @@ def show_mainmenu(self):

listing.append(
TitleItem(title=self._kodi.localize(30009), # Search
path=self._kodi.url_for('show_search', kids=kids),
path=self._kodi.url_for('show_search'),
art_dict=dict(
icon='DefaultAddonsSearch.png'
),
info_dict=dict(
plot=self._kodi.localize(30010),
)))

if self._kodi.get_setting_as_bool('interface_show_kids_zone') and not kids:
listing.append(
TitleItem(title=self._kodi.localize(30011), # Kids Zone
path=self._kodi.url_for('show_main_menu', kids=True),
art_dict=dict(
icon='DefaultUser.png'
),
info_dict=dict(
plot=self._kodi.localize(30012),
)))
listing.append(
TitleItem(title=self._kodi.localize(30011, profile=self._kodi.get_setting('profile_name')), # Switch Profile
path=self._kodi.url_for('select_profile'),
art_dict=dict(
icon='DefaultUser.png'
),
info_dict=dict(
plot=self._kodi.localize(30010),
)))

self._kodi.show_listing(listing, sort=['unsorted'])

Expand Down Expand Up @@ -199,13 +196,13 @@ def generate_titleitem(self, item, progress=False):
context_menu = [(
self._kodi.localize(30101), # Remove from My List
'XBMC.Container.Update(%s)' %
self._kodi.url_for('mylist_del', kids=self._kodi.kids_mode(), video_type=self._vtm_go.CONTENT_TYPE_MOVIE, content_id=item.movie_id)
self._kodi.url_for('mylist_del', video_type=self._vtm_go.CONTENT_TYPE_MOVIE, content_id=item.movie_id)
)]
else:
context_menu = [(
self._kodi.localize(30100), # Add to My List
'XBMC.Container.Update(%s)' %
self._kodi.url_for('mylist_add', kids=self._kodi.kids_mode(), video_type=self._vtm_go.CONTENT_TYPE_MOVIE, content_id=item.movie_id)
self._kodi.url_for('mylist_add', video_type=self._vtm_go.CONTENT_TYPE_MOVIE, content_id=item.movie_id)
)]

art_dict.update({
Expand Down Expand Up @@ -240,13 +237,13 @@ def generate_titleitem(self, item, progress=False):
context_menu = [(
self._kodi.localize(30101), # Remove from My List
'XBMC.Container.Update(%s)' %
self._kodi.url_for('mylist_del', kids=self._kodi.kids_mode(), video_type=self._vtm_go.CONTENT_TYPE_PROGRAM, content_id=item.program_id)
self._kodi.url_for('mylist_del', video_type=self._vtm_go.CONTENT_TYPE_PROGRAM, content_id=item.program_id)
)]
else:
context_menu = [(
self._kodi.localize(30100), # Add to My List
'XBMC.Container.Update(%s)' %
self._kodi.url_for('mylist_add', kids=self._kodi.kids_mode(), video_type=self._vtm_go.CONTENT_TYPE_PROGRAM, content_id=item.program_id)
self._kodi.url_for('mylist_add', video_type=self._vtm_go.CONTENT_TYPE_PROGRAM, content_id=item.program_id)
)]

art_dict.update({
Expand All @@ -267,11 +264,13 @@ def generate_titleitem(self, item, progress=False):
# Episode
#
if isinstance(item, Episode):
context_menu = [(
self._kodi.localize(30102), # Go to Program
'XBMC.Container.Update(%s)' %
self._kodi.url_for('show_catalog_program', program=item.program_id)
)]
context_menu = []
if item.program_id:
context_menu = [(
self._kodi.localize(30102), # Go to Program
'XBMC.Container.Update(%s)' %
self._kodi.url_for('show_catalog_program', program=item.program_id)
)]

art_dict.update({
'fanart': item.cover,
Expand Down
4 changes: 3 additions & 1 deletion resources/lib/modules/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class Metadata:
""" Code responsible for the refreshing of the metadata """

def __init__(self, kodi):
""" Initialise object """
""" Initialise object
:type kodi: resources.lib.kodiwrapper.KodiWrapper
"""
self._kodi = kodi
self._vtm_go = VtmGo(self._kodi)

Expand Down
2 changes: 1 addition & 1 deletion resources/lib/modules/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Player:

def __init__(self, kodi):
""" Initialise object
:type kodi: KodiWrapper
:type kodi: resources.lib.kodiwrapper.KodiWrapper
"""
self._kodi = kodi
self._vtm_go = VtmGo(self._kodi)
Expand Down
Loading

0 comments on commit 8386dfc

Please sign in to comment.