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