Skip to content

Commit 5afdcfd

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 31d0339 commit 5afdcfd

3 files changed

Lines changed: 2 additions & 37 deletions

File tree

resources/lib/apihelper.py

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

341-
play_info = dict(
342-
video_id=next_ep.get('videoId'),
343-
)
344-
345341
next_info = dict(
346342
current_episode=current_episode,
347343
next_episode=next_episode,
348-
play_info=play_info,
344+
play_url='plugin://plugin.video.vrt.nu/play/upnext/%s' % next_ep.get('videoId'),
349345
)
350346
return next_info
351347

resources/lib/playerinfo.py

Lines changed: 1 addition & 13 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 SECONDS_MARGIN
@@ -157,18 +157,6 @@ def stream_position(self):
157157
break
158158
self.onThreadExit()
159159

160-
def add_upnext(self, video_id):
161-
''' Add Up Next url to Kodi Player '''
162-
url = 'plugin://plugin.video.vrt.nu/play/upnext/%s' % video_id
163-
self.update_position()
164-
self.update_total()
165-
if self.isPlaying() and self.total - self.last_pos < 1:
166-
log(3, '[PlayerInfo] %d Add %s to Kodi Playlist' % (self.thread_id, url))
167-
PlayList(1).add(url)
168-
else:
169-
log(3, '[PlayerInfo] %d Add %s to Kodi Player' % (self.thread_id, url))
170-
self.play(url)
171-
172160
def push_upnext(self):
173161
''' Push episode info to Up Next service add-on'''
174162
if has_addon('service.upnext') and get_setting('useupnext', 'true') == 'true':

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):
@@ -42,24 +41,6 @@ def init_watching_activity(self):
4241
if not self._apihelper:
4342
self._apihelper = ApiHelper(self._favorites, self._resumepoints)
4443

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

0 commit comments

Comments
 (0)