Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UpNext play_url support #632

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions resources/lib/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/{video_id}'.format(video_id=next_ep.get('videoId')),
)
return next_info

Expand Down
17 changes: 1 addition & 16 deletions resources/lib/playerinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down
19 changes: 0 additions & 19 deletions resources/lib/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"""

Expand Down