Skip to content

Commit

Permalink
Declare KodiWrapper locally when using reuselanguageinvoker
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister committed Nov 14, 2019
1 parent 34240cd commit 9810c19
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,37 @@

# pylint: disable=invalid-name
plugin = Plugin()
kodi = KodiWrapper(globals())


@plugin.route('/')
def main_menu():
''' The VRT NU plugin main menu '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_main_menu()


@plugin.route('/cache/delete')
@plugin.route('/cache/delete/<cache_file>')
def delete_cache(cache_file='*.json'):
''' The API interface to delete caches '''
kodi = KodiWrapper(globals())
kodi.refresh_caches(cache_file=cache_file)


@plugin.route('/tokens/delete')
def delete_tokens():
''' The API interface to delete all VRT tokens '''
from tokenresolver import TokenResolver
kodi = KodiWrapper(globals())
TokenResolver(kodi).delete_tokens()


@plugin.route('/follow/<program>/<title>')
def follow(program, title):
''' The API interface to follow a program used by the context menu '''
from favorites import Favorites
kodi = KodiWrapper(globals())
Favorites(kodi).follow(program=program, title=to_unicode(unquote_plus(from_unicode(title))))


Expand All @@ -51,20 +54,23 @@ def unfollow(program, title):
''' The API interface to unfollow a program used by the context menu '''
move_down = bool(plugin.args.get('move_down'))
from favorites import Favorites
kodi = KodiWrapper(globals())
Favorites(kodi).unfollow(program=program, title=to_unicode(unquote_plus(from_unicode(title))), move_down=move_down)


@plugin.route('/watchlater/<path:url>/<uuid>/<title>')
def watchlater(uuid, title, url):
''' The API interface to watch an episode used by the context menu '''
from resumepoints import ResumePoints
kodi = KodiWrapper(globals())
ResumePoints(kodi).watchlater(uuid=uuid, title=to_unicode(unquote_plus(from_unicode(title))), url=url)


@plugin.route('/unwatchlater/<path:url>/<uuid>/<title>')
def unwatchlater(uuid, title, url):
''' The API interface to unwatch an episode used by the context menu '''
from resumepoints import ResumePoints
kodi = KodiWrapper(globals())
ResumePoints(kodi).unwatchlater(uuid=uuid, title=to_unicode(unquote_plus(from_unicode(title))), url=url)


Expand All @@ -79,13 +85,15 @@ def favorites_menu():
def favorites_programs():
''' The favorites 'My programs' listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_tvshow_menu(use_favorites=True)


@plugin.route('/favorites/docu')
def favorites_docu():
''' The favorites docu listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_favorites_docu_menu()


Expand All @@ -94,6 +102,7 @@ def favorites_docu():
def favorites_recent(page=1):
''' The favorites recent listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_recent_menu(page=page, use_favorites=True)


Expand All @@ -102,13 +111,15 @@ def favorites_recent(page=1):
def favorites_offline(page=1):
''' The favorites offline listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_offline_menu(page=page, use_favorites=True)


@plugin.route('/favorites/refresh')
def favorites_refresh():
''' The API interface to refresh the favorites cache '''
from favorites import Favorites
kodi = KodiWrapper(globals())
Favorites(kodi).refresh(ttl=0)
kodi.show_notification(message=kodi.localize(30982))

Expand All @@ -117,20 +128,23 @@ def favorites_refresh():
def favorites_manage():
''' The API interface to manage your favorites '''
from favorites import Favorites
kodi = KodiWrapper(globals())
Favorites(kodi).manage()


@plugin.route('/resumepoints/continue')
def resumepoints_continue():
''' The resumepoints continue listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_continue_menu(page=1)


@plugin.route('/resumepoints/refresh')
def resumepoints_refresh():
''' The API interface to refresh the resumepoints cache '''
from resumepoints import ResumePoints
kodi = KodiWrapper(globals())
ResumePoints(kodi).refresh(ttl=0)
kodi.show_notification(message=kodi.localize(30983))

Expand All @@ -139,6 +153,7 @@ def resumepoints_refresh():
def resumepoints_watchlater():
''' The resumepoints watchlater listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_watchlater_menu(page=1)


Expand All @@ -148,6 +163,7 @@ def resumepoints_watchlater():
def programs(program=None, season=None):
''' The Programs / Seasons / Episodes listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
if program:
VRTPlayer(kodi).show_episodes_menu(program=program, season=season)
else:
Expand All @@ -167,13 +183,15 @@ def categories(category=None):
def channels(channel=None):
''' The channels menu and listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_channels_menu(channel=channel)


@plugin.route('/livetv')
def livetv():
''' The livetv menu '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_livetv_menu()


Expand All @@ -182,6 +200,7 @@ def livetv():
def recent(page=1):
''' The most recent items listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_recent_menu(page=page)


Expand All @@ -190,6 +209,7 @@ def recent(page=1):
def offline(page=1):
''' The soon offline listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_offline_menu(page=page)


Expand All @@ -198,6 +218,7 @@ def offline(page=1):
def featured(feature=None):
''' The featured menu and listing '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).show_featured_menu(feature=feature)


Expand All @@ -208,6 +229,7 @@ def featured(feature=None):
def tvguide(date=None, channel=None):
''' The TV guide menu and listings by date '''
from tvguide import TVGuide
kodi = KodiWrapper(globals())
TVGuide(kodi).show_tvguide(date=date, channel=channel)


Expand All @@ -217,34 +239,39 @@ def tvguide(date=None, channel=None):
def tvguide_channel(channel=None, date=None):
''' The TV guide menu and listings by channel '''
from tvguide import TVGuide
kodi = KodiWrapper(globals())
TVGuide(kodi).show_tvguide(channel=channel, date=date)


@plugin.route('/search')
def search():
''' The Search menu and history '''
from search import Search
kodi = KodiWrapper(globals())
Search(kodi).search_menu()


@plugin.route('/search/clear')
def clear_search():
''' Clear the search history '''
from search import Search
kodi = KodiWrapper(globals())
Search(kodi).clear()


@plugin.route('/search/add/<keywords>')
def add_search(keywords):
''' Add to search history '''
from search import Search
kodi = KodiWrapper(globals())
Search(kodi).add(keywords)


@plugin.route('/search/remove/<keywords>')
def remove_search(keywords):
''' Remove from search history '''
from search import Search
kodi = KodiWrapper(globals())
Search(kodi).remove(keywords)


Expand All @@ -254,6 +281,7 @@ def remove_search(keywords):
def search_query(keywords=None, page=1):
''' The Search interface and query listing '''
from search import Search
kodi = KodiWrapper(globals())
Search(kodi).search(keywords=keywords, page=page)


Expand All @@ -262,27 +290,31 @@ def search_query(keywords=None, page=1):
def play_id(video_id, publication_id=None):
''' The API interface to play a video by video_id and/or publication_id '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).play(dict(video_id=video_id, publication_id=publication_id))


@plugin.route('/play/url/<path:video_url>')
def play_url(video_url):
''' The API interface to play a video by using a URL '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).play(dict(video_url=video_url))


@plugin.route('/play/latest/<program>')
def play_latest(program):
''' The API interface to play the latest episode of a program '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).play_latest_episode(program=program)


@plugin.route('/play/whatson/<whatson_id>')
def play_whatson(whatson_id):
''' The API interface to play a video by whatson_id '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).play_whatson(whatson_id=whatson_id)


Expand All @@ -291,10 +323,12 @@ def play_whatson(whatson_id):
def play_by_air_date(channel, start_date, end_date=None):
''' The API interface to play an episode of a program given the channel and the air date in iso format (2019-07-06T19:35:00) '''
from vrtplayer import VRTPlayer
kodi = KodiWrapper(globals())
VRTPlayer(kodi).play_episode_by_air_date(channel, start_date, end_date)


def run(argv):
''' Addon entry point from wrapper '''
kodi = KodiWrapper(globals())
kodi.log_access(argv[0])
plugin.run(argv)

0 comments on commit 9810c19

Please sign in to comment.