Fixes to Watch later & Plex Companion
This commit is contained in:
parent
cddde19cce
commit
5b9b432ca9
5 changed files with 43 additions and 28 deletions
26
default.py
26
default.py
|
@ -103,12 +103,12 @@ class Main():
|
|||
'watchlater': entrypoint.watchlater,
|
||||
'enterPMS': entrypoint.enterPMS,
|
||||
'togglePlexTV': entrypoint.togglePlexTV,
|
||||
'playwatchlater': entrypoint.playWatchLater
|
||||
'Plex_Node': entrypoint.Plex_Node
|
||||
}
|
||||
|
||||
if "/extrafanart" in ARGV[0]:
|
||||
plexpath = ARGV[2][1:]
|
||||
plexid = params.get('id', [""])[0]
|
||||
plexid = params.get('id', [""])
|
||||
entrypoint.getExtraFanArt(plexid, plexpath)
|
||||
entrypoint.getVideoFiles(plexid, plexpath)
|
||||
return
|
||||
|
@ -120,7 +120,7 @@ class Main():
|
|||
# Called by e.g. 3rd party plugin video extras
|
||||
if ("/Extras" in ARGV[0] or "/VideoFiles" in ARGV[0] or
|
||||
"/Extras" in ARGV[2]):
|
||||
plexId = params.get('id', [None])[0]
|
||||
plexId = params.get('id', None)
|
||||
entrypoint.getVideoFiles(plexId, params)
|
||||
|
||||
if modes.get(mode):
|
||||
|
@ -131,35 +131,35 @@ class Main():
|
|||
modes[mode](itemid, dbid)
|
||||
|
||||
elif mode in ("nextup", "inprogressepisodes"):
|
||||
limit = int(params['limit'][0])
|
||||
limit = int(params['limit'])
|
||||
modes[mode](itemid, limit)
|
||||
|
||||
elif mode in ("channels","getsubfolders"):
|
||||
modes[mode](itemid)
|
||||
|
||||
elif mode == "browsecontent":
|
||||
modes[mode](itemid, params.get('type',[""])[0], params.get('folderid',[""])[0])
|
||||
modes[mode](itemid, params.get('type',[""]), params.get('folderid',[""]))
|
||||
|
||||
elif mode == 'browseplex':
|
||||
modes[mode](
|
||||
itemid,
|
||||
params.get('type', [""])[0],
|
||||
params.get('folderid', [""])[0])
|
||||
params.get('type', [""]),
|
||||
params.get('folderid', [""]))
|
||||
|
||||
elif mode in ('ondeck', 'recentepisodes'):
|
||||
modes[mode](
|
||||
itemid,
|
||||
params.get('type', [""])[0],
|
||||
params.get('tagname', [""])[0],
|
||||
int(params.get('limit', [""])[0]))
|
||||
params.get('type', [""]),
|
||||
params.get('tagname', [""]),
|
||||
int(params.get('limit', [""])))
|
||||
|
||||
elif mode == "channelsfolder":
|
||||
folderid = params['folderid'][0]
|
||||
folderid = params['folderid']
|
||||
modes[mode](itemid, folderid)
|
||||
elif mode == "companion":
|
||||
modes[mode](itemid, params=ARGV[2])
|
||||
elif mode == 'playwatchlater':
|
||||
modes[mode](params.get('id')[0], params.get('viewOffset')[0])
|
||||
elif mode == 'Plex_Node':
|
||||
modes[mode](params.get('id'), params.get('viewOffset'))
|
||||
else:
|
||||
modes[mode]()
|
||||
else:
|
||||
|
|
|
@ -11,6 +11,7 @@ from plexbmchelper import listener, plexgdm, subscribers, functions, \
|
|||
httppersist, plexsettings
|
||||
from PlexFunctions import ParseContainerKey
|
||||
import player
|
||||
from entrypoint import Plex_Node
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -74,7 +75,16 @@ class PlexCompanion(Thread):
|
|||
log.debug('Processing: %s' % task)
|
||||
data = task['data']
|
||||
|
||||
if task['action'] == 'playlist':
|
||||
if (task['action'] == 'playlist' and
|
||||
data.get('address') == 'node.plexapp.com'):
|
||||
# E.g. watch later initiated by Companion
|
||||
thread = Thread(target=Plex_Node,
|
||||
args=(data.get('key'),
|
||||
data.get('offset'),
|
||||
data.get('type')))
|
||||
thread.setDaemon(True)
|
||||
thread.start()
|
||||
elif task['action'] == 'playlist':
|
||||
# Get the playqueue ID
|
||||
try:
|
||||
_, ID, query = ParseContainerKey(data['containerKey'])
|
||||
|
|
|
@ -22,6 +22,7 @@ import playbackutils as pbutils
|
|||
|
||||
import PlexFunctions
|
||||
import PlexAPI
|
||||
from playqueue import Playqueue
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -119,19 +120,18 @@ def PassPlaylist(xml, resume=None):
|
|||
resumeId=xml.attrib.get('playQueueSelectedItemID', None))
|
||||
|
||||
|
||||
def playWatchLater(itemid, viewOffset):
|
||||
def Plex_Node(url, viewOffset, playlist_type):
|
||||
"""
|
||||
Called only for a SINGLE element for Plex.tv watch later
|
||||
|
||||
Always to return with a "setResolvedUrl"
|
||||
"""
|
||||
log.info('playWatchLater called with id: %s, viewOffset: %s'
|
||||
% (itemid, viewOffset))
|
||||
log.info('Plex_Node called with url: %s, viewOffset: %s'
|
||||
% (url, viewOffset))
|
||||
# Plex redirect, e.g. watch later. Need to get actual URLs
|
||||
xml = downloadutils.DownloadUtils().downloadUrl(itemid,
|
||||
authenticate=False)
|
||||
xml = downloadutils.DownloadUtils().downloadUrl('{server}%s' % url)
|
||||
if xml in (None, 401):
|
||||
log.error("Could not resolve url %s" % itemid)
|
||||
log.error("Could not resolve url %s" % url)
|
||||
return xbmcplugin.setResolvedUrl(
|
||||
int(sys.argv[1]), False, xbmcgui.ListItem())
|
||||
if viewOffset != '0':
|
||||
|
@ -143,7 +143,9 @@ def playWatchLater(itemid, viewOffset):
|
|||
else:
|
||||
window('plex_customplaylist.seektime', value=str(viewOffset))
|
||||
log.info('Set resume point to %s' % str(viewOffset))
|
||||
return pbutils.PlaybackUtils(xml).play(None, 'plexnode')
|
||||
pbutils.PlaybackUtils(xml, playlist_type=playlist_type).play(
|
||||
None, 'plexnode')
|
||||
return
|
||||
|
||||
|
||||
##### DO RESET AUTH #####
|
||||
|
@ -1237,7 +1239,7 @@ def watchlater():
|
|||
xbmcplugin.setContent(int(sys.argv[1]), 'movies')
|
||||
url = "plugin://plugin.video.plexkodiconnect/"
|
||||
params = {
|
||||
'mode': "playwatchlater",
|
||||
'mode': "Plex_Node",
|
||||
}
|
||||
for item in xml:
|
||||
API = PlexAPI.API(item)
|
||||
|
|
|
@ -20,7 +20,7 @@ from PKC_listitem import PKC_ListItem as ListItem
|
|||
from playlist_func import add_item_to_kodi_playlist, \
|
||||
get_playlist_details_from_xml, add_listitem_to_Kodi_playlist, \
|
||||
add_listitem_to_playlist, remove_from_Kodi_playlist
|
||||
from playqueue import lock
|
||||
from playqueue import lock, Playqueue
|
||||
from pickler import Playback_Successful
|
||||
|
||||
###############################################################################
|
||||
|
@ -34,13 +34,16 @@ addonName = "PlexKodiConnect"
|
|||
|
||||
class PlaybackUtils():
|
||||
|
||||
def __init__(self, item, callback=None):
|
||||
def __init__(self, item, callback=None, playlist_type=None):
|
||||
self.item = item
|
||||
self.api = API(item)
|
||||
playlist_type = playlist_type if playlist_type else KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[self.api.getType()]
|
||||
if callback:
|
||||
self.mgr = callback
|
||||
self.playqueue = self.mgr.playqueue.get_playqueue_from_type(
|
||||
KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[self.api.getType()])
|
||||
self.item = item
|
||||
self.api = API(item)
|
||||
playlist_type)
|
||||
else:
|
||||
self.playqueue = Playqueue().get_playqueue_from_type(playlist_type)
|
||||
|
||||
def play(self, plex_id, kodi_id=None, plex_lib_UUID=None):
|
||||
"""
|
||||
|
|
|
@ -29,7 +29,6 @@ class Playqueue(Thread):
|
|||
|
||||
def __init__(self, callback=None):
|
||||
self.__dict__ = self.__shared_state
|
||||
Thread.__init__(self)
|
||||
if self.playqueues is not None:
|
||||
return
|
||||
self.mgr = callback
|
||||
|
@ -54,6 +53,7 @@ class Playqueue(Thread):
|
|||
self.playqueues = sorted(
|
||||
self.playqueues, key=lambda i: i.playlistid)
|
||||
log.debug('Initialized the Kodi play queues: %s' % self.playqueues)
|
||||
Thread.__init__(self)
|
||||
|
||||
def get_playqueue_from_type(self, typus):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue