Revert "Redesign building Kodi playback list"
This reverts commit 095eba1a74
.
This commit is contained in:
parent
22250b1485
commit
0f6494aa3e
2 changed files with 28 additions and 53 deletions
|
@ -94,8 +94,8 @@ def PassPlaylist(xml, resume=None):
|
||||||
resume = max(resume1, resume2)
|
resume = max(resume1, resume2)
|
||||||
|
|
||||||
pbutils.PlaybackUtils(xml).StartPlay(
|
pbutils.PlaybackUtils(xml).StartPlay(
|
||||||
itemid=xml.attrib.get('playQueueSelectedItemID', None),
|
resume=resume,
|
||||||
resume=resume)
|
resumeId=xml.attrib.get('playQueueSelectedItemID', None))
|
||||||
|
|
||||||
|
|
||||||
def doPlayback(itemid, dbid):
|
def doPlayback(itemid, dbid):
|
||||||
|
@ -128,8 +128,8 @@ def doPlayback(itemid, dbid):
|
||||||
utils.logMsg(title, "No librarySectionUUID found.", 1)
|
utils.logMsg(title, "No librarySectionUUID found.", 1)
|
||||||
|
|
||||||
# Play only 1 item, not playQueue
|
# Play only 1 item, not playQueue
|
||||||
pbutils.PlaybackUtils(item).StartPlay(itemid=itemid,
|
pbutils.PlaybackUtils(item).StartPlay(resume=resume,
|
||||||
resume=resume)
|
resumeId=None)
|
||||||
|
|
||||||
|
|
||||||
##### DO RESET AUTH #####
|
##### DO RESET AUTH #####
|
||||||
|
|
|
@ -39,16 +39,13 @@ class PlaybackUtils():
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
self.pl = playlist.Playlist()
|
self.pl = playlist.Playlist()
|
||||||
|
|
||||||
def StartPlay(self, itemid=None, resume=None):
|
def StartPlay(self, resume=None, resumeId=None):
|
||||||
"""
|
"""
|
||||||
Feed with a PMS playQueue or a single PMS item metadata XML
|
Feed with a PMS playQueue or a single PMS item metadata XML
|
||||||
Every item will get put in playlist
|
Every item will get put in playlist
|
||||||
|
|
||||||
itemid is used to determine the original item supposed to be played
|
|
||||||
"""
|
"""
|
||||||
self.logMsg("StartPlay called with resume=%s, itemid=%s"
|
self.logMsg("StartPlay called with resume=%s, resumeId=%s"
|
||||||
% (resume, itemid), 1)
|
% (resume, resumeId), 1)
|
||||||
self.itemid = itemid
|
|
||||||
self.playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
self.playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
||||||
|
|
||||||
self.startPos = max(self.playlist.getposition(), 0) # Can return -1
|
self.startPos = max(self.playlist.getposition(), 0) # Can return -1
|
||||||
|
@ -65,32 +62,24 @@ class PlaybackUtils():
|
||||||
startPlayer = True if self.startPos == self.sizePlaylist else False
|
startPlayer = True if self.startPos == self.sizePlaylist else False
|
||||||
|
|
||||||
# Run through the passed PMS playlist and construct self.playlist
|
# Run through the passed PMS playlist and construct self.playlist
|
||||||
listtuples = []
|
listitems = []
|
||||||
for mediaItem in self.item:
|
for mediaItem in self.item:
|
||||||
listtuples += self.AddMediaItemToPlaylist(mediaItem)
|
listitems += self.AddMediaItemToPlaylist(mediaItem)
|
||||||
|
|
||||||
# Kick off playback; no worries about overwriting initial listitem
|
# Kick off playback
|
||||||
if startPlayer:
|
if startPlayer:
|
||||||
self.logMsg("Starting new playback", 1)
|
|
||||||
Player = xbmc.Player()
|
Player = xbmc.Player()
|
||||||
Player.play(self.playlist, startpos=self.startPos)
|
Player.play(self.playlist, startpos=self.startPos)
|
||||||
if resume:
|
if resume:
|
||||||
Player.seekTime(resume)
|
try:
|
||||||
# Kodi has already started playing; overwrite initial listitem to
|
Player.seekTime(resume)
|
||||||
# preserve resume timing on the Kodi side. No trailers anyway
|
except:
|
||||||
elif resume > 0:
|
self.logMsg("Error, could not resume", -1)
|
||||||
self.logMsg("Overwritten Kodi listitem for resume. Pos: %s"
|
|
||||||
% [x for (x, y) in listtuples if
|
|
||||||
x == self.newStartPos][0], 1)
|
|
||||||
startitem = [y for (x, y) in listtuples if
|
|
||||||
x == self.newStartPos][0]
|
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, startitem)
|
|
||||||
# No resume point given; start with very first item in our playlist
|
|
||||||
else:
|
else:
|
||||||
self.logMsg("No resume; start from beginning", 1)
|
# Delete the last playlist item because we have added it already
|
||||||
startitem = [y for (x, y) in listtuples if
|
filename = self.playlist[-1].getfilename()
|
||||||
x == self.startPos][0]
|
self.playlist.remove(filename)
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, startitem)
|
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitems[0])
|
||||||
|
|
||||||
def AddMediaItemToPlaylist(self, item):
|
def AddMediaItemToPlaylist(self, item):
|
||||||
"""
|
"""
|
||||||
|
@ -105,8 +94,7 @@ class PlaybackUtils():
|
||||||
playutils = putils.PlayUtils(item)
|
playutils = putils.PlayUtils(item)
|
||||||
|
|
||||||
# Get playurls per part and process them
|
# Get playurls per part and process them
|
||||||
listtuples = []
|
listitems = []
|
||||||
gotStart = False
|
|
||||||
for playurl in playutils.getPlayUrl():
|
for playurl in playutils.getPlayUrl():
|
||||||
# One new listitem per part
|
# One new listitem per part
|
||||||
listitem = xbmcgui.ListItem()
|
listitem = xbmcgui.ListItem()
|
||||||
|
@ -122,34 +110,21 @@ class PlaybackUtils():
|
||||||
self.setProperties(playurl, listitem)
|
self.setProperties(playurl, listitem)
|
||||||
# Set metadata
|
# Set metadata
|
||||||
self.setListItem(listitem)
|
self.setListItem(listitem)
|
||||||
|
self.playlist.add(
|
||||||
|
playurl, listitem, index=self.currentPosition)
|
||||||
|
|
||||||
playQueueItemID = self.API.GetPlayQueueItemID()
|
listitems.append(listitem)
|
||||||
# This is the 1 part we need to start with (otherwise resume is
|
|
||||||
# lost on the Kodi side). Skip adding a playlist item; overwrite!
|
|
||||||
if (not gotStart and (self.itemid == self.API.getRatingKey() or
|
|
||||||
self.itemid == playQueueItemID)):
|
|
||||||
self.logMsg("Item to start with has playlist position %s"
|
|
||||||
% (self.currentPosition), 1)
|
|
||||||
# Safe place we're at for later
|
|
||||||
self.newStartPos = self.currentPosition
|
|
||||||
# Set flag that we found (first ;-)) start item/part
|
|
||||||
gotStart = True
|
|
||||||
# Otherwise, add a new playlist item
|
|
||||||
else:
|
|
||||||
self.playlist.add(
|
|
||||||
playurl, listitem, index=self.currentPosition)
|
|
||||||
|
|
||||||
listtuples.append((self.currentPosition, listitem))
|
|
||||||
self.currentPosition += 1
|
self.currentPosition += 1
|
||||||
|
|
||||||
# We need to keep track of playQueueItemIDs for Plex Companion
|
# We need to keep track of playQueueItemIDs for Plex Companion
|
||||||
|
playQueueItemID = self.API.GetPlayQueueItemID()
|
||||||
utils.window(
|
utils.window(
|
||||||
'plex_%s.playQueueItemID' % playurl, playQueueItemID)
|
'plex_%s.playQueueItemID' % playurl, playQueueItemID)
|
||||||
utils.window(
|
utils.window(
|
||||||
'plex_%s.playlistPosition'
|
'plex_%s.playlistPosition'
|
||||||
% playurl, str(self.currentPosition))
|
% playurl, str(self.currentPosition))
|
||||||
|
|
||||||
return listtuples
|
return listitems
|
||||||
|
|
||||||
def setProperties(self, playurl, listitem):
|
def setProperties(self, playurl, listitem):
|
||||||
# Set all properties necessary for plugin path playback
|
# Set all properties necessary for plugin path playback
|
||||||
|
@ -258,26 +233,26 @@ class PlaybackUtils():
|
||||||
mediaType = API.getType()
|
mediaType = API.getType()
|
||||||
people = API.getPeople()
|
people = API.getPeople()
|
||||||
|
|
||||||
# userdata = API.getUserData()
|
userdata = API.getUserData()
|
||||||
title, sorttitle = API.getTitle()
|
title, sorttitle = API.getTitle()
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
'genre': API.joinList(API.getGenres()),
|
'genre': API.joinList(API.getGenres()),
|
||||||
'year': API.getYear(),
|
'year': API.getYear(),
|
||||||
'rating': API.getAudienceRating(),
|
'rating': API.getAudienceRating(),
|
||||||
# 'playcount': userdata['PlayCount'],
|
'playcount': userdata['PlayCount'],
|
||||||
'cast': people['Cast'],
|
'cast': people['Cast'],
|
||||||
'director': API.joinList(people.get('Director')),
|
'director': API.joinList(people.get('Director')),
|
||||||
'plot': API.getPlot(),
|
'plot': API.getPlot(),
|
||||||
'title': title,
|
'title': title,
|
||||||
'sorttitle': sorttitle,
|
'sorttitle': sorttitle,
|
||||||
# 'duration': userdata['Runtime'],
|
'duration': userdata['Runtime'],
|
||||||
'studio': API.joinList(API.getStudios()),
|
'studio': API.joinList(API.getStudios()),
|
||||||
'tagline': API.getTagline(),
|
'tagline': API.getTagline(),
|
||||||
'writer': API.joinList(people.get('Writer')),
|
'writer': API.joinList(people.get('Writer')),
|
||||||
'premiered': API.getPremiereDate(),
|
'premiered': API.getPremiereDate(),
|
||||||
'dateadded': API.getDateCreated(),
|
'dateadded': API.getDateCreated(),
|
||||||
# 'lastplayed': userdata['LastPlayedDate'],
|
'lastplayed': userdata['LastPlayedDate'],
|
||||||
'mpaa': API.getMpaa(),
|
'mpaa': API.getMpaa(),
|
||||||
'aired': API.getPremiereDate(),
|
'aired': API.getPremiereDate(),
|
||||||
'votes': None
|
'votes': None
|
||||||
|
|
Loading…
Reference in a new issue