Always post to PMS to get playQueue
This commit is contained in:
parent
ee86f58a3f
commit
253feb9c69
3 changed files with 40 additions and 30 deletions
|
@ -384,23 +384,22 @@ def GetPlexCollections(mediatype):
|
|||
return collections
|
||||
|
||||
|
||||
def GetPlexPlaylist(itemid, librarySectionUUID, mediatype='movie'):
|
||||
def GetPlexPlaylist(itemid, librarySectionUUID, mediatype='movie',
|
||||
trailers=False):
|
||||
"""
|
||||
Returns raw API metadata XML dump for a playlist with e.g. trailers.
|
||||
"""
|
||||
trailerNumber = settings('trailerNumber')
|
||||
if not trailerNumber:
|
||||
trailerNumber = '3'
|
||||
url = "{server}/playQueues"
|
||||
args = {
|
||||
'type': mediatype,
|
||||
'uri': ('library://' + librarySectionUUID +
|
||||
'/item/%2Flibrary%2Fmetadata%2F' + itemid),
|
||||
'includeChapters': '1',
|
||||
'extrasPrefixCount': trailerNumber,
|
||||
'shuffle': '0',
|
||||
'repeat': '0'
|
||||
}
|
||||
if trailers is True:
|
||||
args['extrasPrefixCount'] = settings('trailerNumber')
|
||||
xml = downloadutils.DownloadUtils().downloadUrl(
|
||||
url + '?' + urlencode(args), action_type="POST")
|
||||
try:
|
||||
|
|
|
@ -37,11 +37,7 @@ class PlaybackUtils():
|
|||
|
||||
self.userid = window('currUserId')
|
||||
self.server = window('pms_server')
|
||||
playqueue = Playqueue()
|
||||
# We need to initialize already existing items as we have a completely
|
||||
# different Python instance!
|
||||
playqueue.init_playlists()
|
||||
self.pl = playqueue.get_playqueue_from_type(
|
||||
self.pl = Playqueue().get_playqueue_from_type(
|
||||
PF.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[item[0].attrib.get('type')])
|
||||
|
||||
def play(self, itemid, dbid=None):
|
||||
|
@ -124,6 +120,22 @@ class PlaybackUtils():
|
|||
window('plex_playbackProps', value="true")
|
||||
log.info("Setting up properties in playlist.")
|
||||
|
||||
# Post playQueue to PMS
|
||||
trailers = False
|
||||
if settings('enableCinema') == "true":
|
||||
if settings('askCinema') == "true":
|
||||
trailers = xbmcgui.Dialog().yesno(addonName,
|
||||
"Play trailers?")
|
||||
else:
|
||||
trailers = True
|
||||
xml = PF.GetPlexPlaylist(
|
||||
itemid,
|
||||
item.attrib.get('librarySectionUUID'),
|
||||
mediatype=API.getType(),
|
||||
trailers=trailers)
|
||||
# Save playQueueID for other PKC python instance & kodimonitor
|
||||
window('plex_playQueueID', value=xml.attrib.get('playQueueID'))
|
||||
|
||||
if (not homeScreen and not seektime and
|
||||
window('plex_customplaylist') != "true" and
|
||||
not contextmenu_play):
|
||||
|
@ -148,12 +160,8 @@ class PlaybackUtils():
|
|||
self.currentPosition += 1
|
||||
|
||||
############### -- CHECK FOR INTROS ################
|
||||
if (settings('enableCinema') == "true" and not seektime):
|
||||
if trailers and not seektime:
|
||||
# if we have any play them when the movie/show is not being resumed
|
||||
xml = PF.GetPlexPlaylist(
|
||||
itemid,
|
||||
item.attrib.get('librarySectionUUID'),
|
||||
mediatype=API.getType())
|
||||
introsPlaylist = self.AddTrailers(xml)
|
||||
|
||||
############### -- ADD MAIN ITEM ONLY FOR HOMESCREEN ##############
|
||||
|
@ -278,13 +286,6 @@ class PlaybackUtils():
|
|||
if xml.attrib.get('size') == '1':
|
||||
return False
|
||||
|
||||
if settings('askCinema') == "true":
|
||||
resp = xbmcgui.Dialog().yesno(addonName, "Play trailers?")
|
||||
if not resp:
|
||||
# User selected to not play trailers
|
||||
log.info("Skip trailers.")
|
||||
return False
|
||||
|
||||
# Playurl needs to point back so we can get metadata!
|
||||
path = "plugin://plugin.video.plexkodiconnect.movies/"
|
||||
params = {
|
||||
|
|
|
@ -79,6 +79,13 @@ class Playqueue(Thread):
|
|||
% kodi_player_id)
|
||||
return playqueue
|
||||
|
||||
def _grab_PMS_playqueue(self, playqueue, playqueue_id=None, repeat=None):
|
||||
"""
|
||||
For initiating out playqueues from the PMS because another PKC Python
|
||||
instance already is setting up the Kodi playlists
|
||||
"""
|
||||
PL.grab_PMS_playqueue(playqueue, playqueue_id)
|
||||
|
||||
@lockmethod.lockthis
|
||||
def update_playqueue_from_PMS(self,
|
||||
playqueue,
|
||||
|
@ -96,7 +103,6 @@ class Playqueue(Thread):
|
|||
PL.update_playlist_from_PMS(playqueue, playqueue_id)
|
||||
playqueue.repeat = 0 if not repeat else int(repeat)
|
||||
log.debug('Updated playqueue: %s' % playqueue)
|
||||
|
||||
window('plex_customplaylist', value="true")
|
||||
if offset not in (None, "0"):
|
||||
window('plex_customplaylist.seektime',
|
||||
|
@ -153,13 +159,14 @@ class Playqueue(Thread):
|
|||
}
|
||||
"""
|
||||
playqueue = self.playqueues[data['playlistid']]
|
||||
if data['item'].get('id') is None and data['item'].get('file') is None:
|
||||
# Kodi screwed up. Let's try to get the data anyway
|
||||
items = PL.get_kodi_playlist_items(playqueue)
|
||||
if items[data['position']].get('id') is not None:
|
||||
data['item']['id'] = items[data['position']].get('id')
|
||||
else:
|
||||
data['item']['file'] = items[data['position']].get('file')
|
||||
if window('plex_playbackProps') == 'true':
|
||||
log.debug('kodi_onadd called during PKC playback setup')
|
||||
if window('plex_playQueueID'):
|
||||
self._grab_PMS_playqueue(playqueue, window('plex_playQueueID'))
|
||||
window('plex_playQueueID', clear=True)
|
||||
log.debug('Done setting up playQueue')
|
||||
return
|
||||
|
||||
if playqueue.PKC_playlist_edits:
|
||||
old = (data['item'].get('id') if data['item'].get('id')
|
||||
else data['item'].get('file'))
|
||||
|
@ -182,6 +189,9 @@ class Playqueue(Thread):
|
|||
RPC output, e.g.
|
||||
{u'position': 2, u'playlistid': 1}
|
||||
"""
|
||||
if window('plex_playbackProps') == 'true':
|
||||
log.debug('kodi_onremove called during PKC playback setup')
|
||||
return
|
||||
playqueue = self.playqueues[data['playlistid']]
|
||||
PL.delete_playlist_item(playqueue, data['position'])
|
||||
log.debug('Deleted item at position %s. New playqueue: %s'
|
||||
|
|
Loading…
Reference in a new issue