Adjust Plex Companion playQueues being passed to PlexKodiConnect to use playlist playall

This commit is contained in:
tomkat83 2016-02-10 13:50:04 +01:00
parent 531dba40bf
commit ea63801a2b
5 changed files with 39 additions and 37 deletions

View file

@ -132,7 +132,7 @@ def GetPlayQueue(playQueueID):
"""
Fetches the PMS playqueue with the playQueueID as an XML
Returns False if something went wrong
Returns None if something went wrong
"""
url = "{server}/playQueues/%s" % playQueueID
args = {'Accept': 'application/xml'}
@ -140,7 +140,7 @@ def GetPlayQueue(playQueueID):
try:
xml.attrib['playQueueID']
except (AttributeError, KeyError):
return False
return None
return xml

View file

@ -23,8 +23,8 @@ import embydb_functions as embydb
import playbackutils as pbutils
import playutils
import api
import playlist
import PlexAPI
import PlexFunctions
#################################################################################################
@ -53,21 +53,23 @@ def plexCompanion(fullurl, params):
params['containerKey'])
# Construct a container key that works always (get rid of playlist args)
utils.window('containerKey', '/'+library+'/'+key)
# Assume it's video when something goes wrong
playbackType = params.get('type', 'video')
if 'playQueues' in library:
utils.logMsg(title, "Playing a playQueue. Query was: %s" % query, 1)
# Playing a playlist that we need to fetch from PMS
xml = PlexFunctions.GetPlayQueue(key)
if not xml:
if xml is None:
utils.logMsg(
title, "Error getting PMS playlist for key %s" % key, -1)
return
else:
PassPlaylist(
xml,
resume=PlexFunctions.ConvertPlexToKodiTime(
params.get('offset', 0)))
resume = PlexFunctions.ConvertPlexToKodiTime(
params.get('offset', 0))
itemids = []
for item in xml:
itemids.append(item.get('ratingKey'))
return playlist.Playlist().playAll(itemids, resume)
else:
utils.logMsg(
title, "Not knowing what to do for now - no playQueue sent", -1)
@ -104,7 +106,7 @@ def doPlayback(itemid, dbid):
item = PlexFunctions.GetPlexMetadata(itemid)
if item is None:
return False
pbutils.PlaybackUtils(item).play(itemid, dbid)
return pbutils.PlaybackUtils(item).play(itemid, dbid)
# utils.logMsg(title, "doPlayback called with itemid=%s, dbid=%s"
# % (itemid, dbid), 1)

View file

@ -12,7 +12,6 @@ import xbmcplugin
import artwork
import clientinfo
import downloadutils
import playutils as putils
import playlist
import read_embyserver as embyserver
@ -117,7 +116,8 @@ class PlaybackUtils():
############### -- CHECK FOR INTROS ################
if utils.settings('enableCinema') == "true" and not seektime:
if (utils.settings('enableCinema') == "true" and not seektime and
not utils.window('emby_customPlaylist') == "true"):
# if we have any play them when the movie/show is not being resumed
xml = PF.GetPlexPlaylist(
itemid,
@ -143,6 +143,11 @@ class PlaybackUtils():
if len(item[0][0]) > 1:
# Only add to the playlist after intros have played
for counter, part in enumerate(item[0][0]):
# Playlist items don't fail on their first call - skip them
# here, otherwise we'll get two 1st parts
if (counter == 0 and
utils.window('emby_customPlaylist') == "true"):
continue
# Set listitem and properties for each additional parts
API.setPartNumber(counter)
additionalListItem = xbmcgui.ListItem()

View file

@ -113,7 +113,7 @@ class Player(xbmc.Player):
# Start at, when using custom playlist (play to Kodi from webclient)
seektime = utils.window('emby_customPlaylist.seektime')
self.logMsg("Seeking to: %s" % seektime, 1)
xbmcplayer.seekTime(int(seektime)/10000000.0)
xbmcplayer.seekTime(int(seektime)*1000.0)
utils.window('emby_customPlaylist.seektime', clear=True)
seekTime = xbmcplayer.getTime()

View file

@ -26,11 +26,6 @@ class Playlist():
self.emby = embyserver.Read_EmbyServer()
def playAll(self, itemids, startat):
embyconn = utils.kodiSQL('emby')
embycursor = embyconn.cursor()
emby_db = embydb.Embydb_Functions(embycursor)
player = xbmc.Player()
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.clear()
@ -45,6 +40,7 @@ class Playlist():
# Seek to the starting position
utils.window('emby_customplaylist.seektime', str(startat))
with embydb.GetEmbyDB() as emby_db:
for itemid in itemids:
embydb_item = emby_db.getItem_byId(itemid)
try:
@ -66,7 +62,6 @@ class Playlist():
player.play(playlist)
self.verifyPlaylist()
embycursor.close()
def modifyPlaylist(self, itemids):