Skip to content

Commit 9ccad49

Browse files
committed
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)
1 parent 081c9ef commit 9ccad49

File tree

3 files changed

+2
-40
lines changed

3 files changed

+2
-40
lines changed

resources/lib/apihelper.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,10 @@ def get_upnext(self, info):
340340
runtime=self._metadata.get_duration(next_ep),
341341
)
342342

343-
play_info = dict(
344-
video_id=next_ep.get('videoId'),
345-
)
346-
347343
next_info = dict(
348344
current_episode=current_episode,
349345
next_episode=next_episode,
350-
play_info=play_info,
346+
play_url='plugin://plugin.video.vrt.nu/play/upnext/%s' % next_ep.get('videoId'),
351347
)
352348
return next_info
353349

resources/lib/playerinfo.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from __future__ import absolute_import, division, unicode_literals
66
from threading import Event, Thread
7-
from xbmc import getInfoLabel, Player, PlayList
7+
from xbmc import getInfoLabel, Player
88

99
from apihelper import ApiHelper
1010
from data import CHANNELS
@@ -184,21 +184,6 @@ def stream_position(self):
184184
break
185185
self.onPlayerExit()
186186

187-
def add_upnext(self, video_id):
188-
"""Add Up Next url to Kodi Player"""
189-
# Reset vrtnu_resumepoints property
190-
set_property('vrtnu_resumepoints', None)
191-
192-
url = 'plugin://plugin.video.vrt.nu/play/upnext/{video_id}'.format(video_id=video_id)
193-
self.update_position()
194-
self.update_total()
195-
if self.isPlaying() and self.total - self.last_pos < 1:
196-
log(3, '[PlayerInfo {id}] Add {url} to Kodi Playlist', id=self.thread_id, url=url)
197-
PlayList(1).add(url)
198-
else:
199-
log(3, '[PlayerInfo {id}] Add {url} to Kodi Player', id=self.thread_id, url=url)
200-
self.play(url)
201-
202187
def push_upnext(self):
203188
"""Push episode info to Up Next service add-on"""
204189
if has_addon('service.upnext') and get_setting_bool('useupnext', default=True) and self.isPlaying():

resources/lib/service.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from playerinfo import PlayerInfo
1111
from resumepoints import ResumePoints
1212
from tokenresolver import TokenResolver
13-
from utils import to_unicode
1413

1514

1615
class VrtMonitor(Monitor, object): # pylint: disable=useless-object-inheritance
@@ -44,24 +43,6 @@ def init_watching_activity(self):
4443
else:
4544
self._playerinfo = None
4645

47-
def onNotification(self, sender, method, data): # pylint: disable=invalid-name
48-
"""Handler for notifications"""
49-
# log(2, '[Notification] sender={sender}, method={method}, data={data}', sender=sender, method=method, data=to_unicode(data))
50-
51-
# Handle play_action events from upnextprovider
52-
if sender.startswith('upnextprovider') and method.endswith('plugin.video.vrt.nu_play_action'):
53-
from json import loads
54-
hexdata = loads(data)
55-
56-
if not hexdata:
57-
return
58-
59-
# NOTE: With Python 3.5 and older json.loads() does not support bytes or bytearray, so we convert to unicode
60-
from base64 import b64decode
61-
data = loads(to_unicode(b64decode(hexdata[0])))
62-
log(2, '[Up Next notification] sender={sender}, method={method}, data={data}', sender=sender, method=method, data=to_unicode(data))
63-
self._playerinfo.add_upnext(data.get('video_id'))
64-
6546
def onSettingsChanged(self): # pylint: disable=invalid-name
6647
"""Handler for changes to settings"""
6748

0 commit comments

Comments
 (0)