From a92659e96d62148a2bb5c80d3022965fc775ba30 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 | 14 +------------- resources/lib/service.py | 19 ------------------- 3 files changed, 2 insertions(+), 37 deletions(-) diff --git a/resources/lib/apihelper.py b/resources/lib/apihelper.py index 749ea3061..f38014eb9 100644 --- a/resources/lib/apihelper.py +++ b/resources/lib/apihelper.py @@ -338,14 +338,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 638746a88..9ac9fa361 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 SECONDS_MARGIN @@ -153,18 +153,6 @@ def stream_position(self): break self.onThreadExit() - def add_upnext(self, video_id): - ''' Add Up Next url to Kodi Player ''' - url = 'plugin://plugin.video.vrt.nu/play/upnext/%s' % video_id - self.update_position() - self.update_total() - if self.isPlaying() and self.total - self.last_pos < 1: - log(3, '[PlayerInfo] %d Add %s to Kodi Playlist' % (self.thread_id, url)) - PlayList(1).add(url) - else: - log(3, '[PlayerInfo] %d Add %s to Kodi Player' % (self.thread_id, 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('useupnext', 'true') == 'true' and self.isPlaying(): diff --git a/resources/lib/service.py b/resources/lib/service.py index 02e118790..7c8abe7c6 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): @@ -42,24 +41,6 @@ def init_watching_activity(self): if not self._apihelper: self._apihelper = ApiHelper(self._favorites, self._resumepoints) - 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 '''