From 432b09481f388d98eaf9db7d20360a059425c249 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Tue, 10 Dec 2019 11:53:21 +0100 Subject: [PATCH] Add UpNext play_url support This adds UpNext `play_url` support and removes the old interface. The aim is to move this functionality to Up Next so it is easier to integrate with Up Next and offer the best experience in Up Next. (Without work-arounds in VRT NU) --- resources/lib/apihelper.py | 6 +----- resources/lib/playerinfo.py | 17 +---------------- resources/lib/service.py | 19 ------------------- 3 files changed, 2 insertions(+), 40 deletions(-) diff --git a/resources/lib/apihelper.py b/resources/lib/apihelper.py index 89f72bcdb..24503a253 100644 --- a/resources/lib/apihelper.py +++ b/resources/lib/apihelper.py @@ -350,14 +350,10 @@ def get_upnext(self, info): runtime=self._metadata.get_duration(next_ep), ) - play_info = dict( - video_id=next_ep.get('videoId'), - ) - next_info = dict( current_episode=current_episode, next_episode=next_episode, - play_info=play_info, + play_url='plugin://plugin.video.vrt.nu/play/upnext/%s' % next_ep.get('videoId'), ) return next_info diff --git a/resources/lib/playerinfo.py b/resources/lib/playerinfo.py index 3ca61b02e..364536551 100644 --- a/resources/lib/playerinfo.py +++ b/resources/lib/playerinfo.py @@ -4,7 +4,7 @@ from __future__ import absolute_import, division, unicode_literals from threading import Event, Thread -from xbmc import getInfoLabel, Player, PlayList +from xbmc import getInfoLabel, Player from apihelper import ApiHelper from data import CHANNELS @@ -185,21 +185,6 @@ def stream_position(self): break self.onPlayerExit() - def add_upnext(self, video_id): - """Add Up Next url to Kodi Player""" - # Reset vrtnu_resumepoints property - set_property('vrtnu_resumepoints', None) - - url = 'plugin://plugin.video.vrt.nu/play/upnext/{video_id}'.format(video_id=video_id) - self.update_position() - self.update_total() - if self.isPlaying() and self.total - self.last_pos < 1: - log(3, '[PlayerInfo {id}] Add {url} to Kodi Playlist', id=self.thread_id, url=url) - PlayList(1).add(url) - else: - log(3, '[PlayerInfo {id}] Add {url} to Kodi Player', id=self.thread_id, url=url) - self.play(url) - def push_upnext(self): """Push episode info to Up Next service add-on""" if has_addon('service.upnext') and get_setting_bool('useupnext', default=True) and self.isPlaying(): diff --git a/resources/lib/service.py b/resources/lib/service.py index 4005fb8ee..86a9e5062 100644 --- a/resources/lib/service.py +++ b/resources/lib/service.py @@ -10,7 +10,6 @@ from playerinfo import PlayerInfo from resumepoints import ResumePoints from tokenresolver import TokenResolver -from utils import to_unicode class VrtMonitor(Monitor, object): # pylint: disable=useless-object-inheritance @@ -44,24 +43,6 @@ def init_watching_activity(self): else: self._playerinfo = None - def onNotification(self, sender, method, data): # pylint: disable=invalid-name - """Handler for notifications""" - # log(2, '[Notification] sender={sender}, method={method}, data={data}', sender=sender, method=method, data=to_unicode(data)) - - # Handle play_action events from upnextprovider - if sender.startswith('upnextprovider') and method.endswith('plugin.video.vrt.nu_play_action'): - from json import loads - hexdata = loads(data) - - if not hexdata: - return - - # NOTE: With Python 3.5 and older json.loads() does not support bytes or bytearray, so we convert to unicode - from base64 import b64decode - data = loads(to_unicode(b64decode(hexdata[0]))) - log(2, '[Up Next notification] sender={sender}, method={method}, data={data}', sender=sender, method=method, data=to_unicode(data)) - self._playerinfo.add_upnext(data.get('video_id')) - def onSettingsChanged(self): # pylint: disable=invalid-name """Handler for changes to settings"""