Playbackutils now cycles correctly over XML reply; trailers thus working
This commit is contained in:
parent
7f9dfca2d6
commit
1970e00b16
4 changed files with 26 additions and 21 deletions
|
@ -1290,6 +1290,12 @@ class API():
|
||||||
self.child = number
|
self.child = number
|
||||||
self.logMsg("Set child number to %s" % number, 1)
|
self.logMsg("Set child number to %s" % number, 1)
|
||||||
|
|
||||||
|
def getChild(self):
|
||||||
|
"""
|
||||||
|
Returns the child in the XML response that we're currently looking at
|
||||||
|
"""
|
||||||
|
return self.child
|
||||||
|
|
||||||
def convert_date(self, stamp):
|
def convert_date(self, stamp):
|
||||||
"""
|
"""
|
||||||
convert_date(stamp) converts a Unix time stamp (seconds passed since
|
convert_date(stamp) converts a Unix time stamp (seconds passed since
|
||||||
|
|
|
@ -31,8 +31,10 @@ import PlexAPI
|
||||||
|
|
||||||
|
|
||||||
def doPlayback(itemid, dbid):
|
def doPlayback(itemid, dbid):
|
||||||
|
# Get a first XML to get the librarySectionUUID
|
||||||
item = PlexAPI.PlexAPI().GetPlexMetadata(itemid) # Now xml, not json!
|
item = PlexAPI.PlexAPI().GetPlexMetadata(itemid)
|
||||||
|
# Use that to call the playlist
|
||||||
|
item = PlexAPI.API(item).GetPlexPlaylist()
|
||||||
pbutils.PlaybackUtils(item).play(itemid, dbid)
|
pbutils.PlaybackUtils(item).play(itemid, dbid)
|
||||||
|
|
||||||
##### DO RESET AUTH #####
|
##### DO RESET AUTH #####
|
||||||
|
|
|
@ -9,7 +9,6 @@ import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import xbmcplugin
|
import xbmcplugin
|
||||||
|
|
||||||
import api
|
|
||||||
import artwork
|
import artwork
|
||||||
import clientinfo
|
import clientinfo
|
||||||
import downloadutils
|
import downloadutils
|
||||||
|
@ -37,6 +36,7 @@ class PlaybackUtils():
|
||||||
|
|
||||||
self.userid = utils.window('emby_currUser')
|
self.userid = utils.window('emby_currUser')
|
||||||
self.server = utils.window('emby_server%s' % self.userid)
|
self.server = utils.window('emby_server%s' % self.userid)
|
||||||
|
self.machineIdentifier = utils.window('plex_machineIdentifier')
|
||||||
|
|
||||||
self.artwork = artwork.Artwork()
|
self.artwork = artwork.Artwork()
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
|
@ -47,7 +47,6 @@ class PlaybackUtils():
|
||||||
self.className = self.__class__.__name__
|
self.className = self.__class__.__name__
|
||||||
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
||||||
|
|
||||||
|
|
||||||
def play(self, itemid, dbid=None):
|
def play(self, itemid, dbid=None):
|
||||||
|
|
||||||
self.logMsg("Play called.", 1)
|
self.logMsg("Play called.", 1)
|
||||||
|
@ -58,7 +57,10 @@ class PlaybackUtils():
|
||||||
listitem = xbmcgui.ListItem()
|
listitem = xbmcgui.ListItem()
|
||||||
playutils = putils.PlayUtils(item)
|
playutils = putils.PlayUtils(item)
|
||||||
|
|
||||||
playurl = playutils.getPlayUrl()
|
# Set child number to the very last one, because that's what we want
|
||||||
|
# to play ultimately
|
||||||
|
API.setChildNumber(-1)
|
||||||
|
playurl = playutils.getPlayUrl(child=-1)
|
||||||
if not playurl:
|
if not playurl:
|
||||||
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem)
|
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem)
|
||||||
|
|
||||||
|
@ -105,21 +107,13 @@ class PlaybackUtils():
|
||||||
# Remove the original item from playlist
|
# Remove the original item from playlist
|
||||||
self.pl.removefromPlaylist(startPos+1)
|
self.pl.removefromPlaylist(startPos+1)
|
||||||
# Readd the original item to playlist - via jsonrpc so we have full metadata
|
# Readd the original item to playlist - via jsonrpc so we have full metadata
|
||||||
self.pl.insertintoPlaylist(currentPosition+1, dbid, item[0].attrib['type'].lower())
|
self.pl.insertintoPlaylist(currentPosition+1, dbid, item[-1].attrib['type'].lower())
|
||||||
currentPosition += 1
|
currentPosition += 1
|
||||||
|
|
||||||
############### -- CHECK FOR INTROS ################
|
############### -- CHECK FOR INTROS ################
|
||||||
# PLEX: todo. Seems like Plex returns a playlist WITH trailers
|
|
||||||
if utils.settings('enableCinema') == "true" and not seektime:
|
if utils.settings('enableCinema') == "true" and not seektime:
|
||||||
# if we have any play them when the movie/show is not being resumed
|
# if we have any play them when the movie/show is not being resumed
|
||||||
# Download XML playlist associated with the picked movie
|
playListSize = int(item.attrib['size'])
|
||||||
self.item = API.GetPlexPlaylist()
|
|
||||||
item = self.item
|
|
||||||
# And overwrite instances with new item
|
|
||||||
self.API = PlexAPI.API(item)
|
|
||||||
API = self.API
|
|
||||||
playutils = putils.PlayUtils(item)
|
|
||||||
playListSize = int(self.item.attrib['size'])
|
|
||||||
if playListSize > 1:
|
if playListSize > 1:
|
||||||
getTrailers = True
|
getTrailers = True
|
||||||
if utils.settings('askCinema') == "true":
|
if utils.settings('askCinema') == "true":
|
||||||
|
@ -134,7 +128,7 @@ class PlaybackUtils():
|
||||||
# Set the child in XML Plex response to a trailer
|
# Set the child in XML Plex response to a trailer
|
||||||
API.setChildNumber(i)
|
API.setChildNumber(i)
|
||||||
introListItem = xbmcgui.ListItem()
|
introListItem = xbmcgui.ListItem()
|
||||||
introPlayurl = playutils.getPlayUrl()
|
introPlayurl = playutils.getPlayUrl(child=i)
|
||||||
self.logMsg("Adding Trailer: %s" % introPlayurl, 1)
|
self.logMsg("Adding Trailer: %s" % introPlayurl, 1)
|
||||||
# Set listitem and properties for intros
|
# Set listitem and properties for intros
|
||||||
self.setProperties(introPlayurl, introListItem)
|
self.setProperties(introPlayurl, introListItem)
|
||||||
|
@ -142,9 +136,10 @@ class PlaybackUtils():
|
||||||
self.pl.insertintoPlaylist(currentPosition, url=introPlayurl)
|
self.pl.insertintoPlaylist(currentPosition, url=introPlayurl)
|
||||||
introsPlaylist = True
|
introsPlaylist = True
|
||||||
currentPosition += 1
|
currentPosition += 1
|
||||||
|
self.logMsg("Key: %s" % API.getKey(), 1)
|
||||||
self.logMsg("Successfally added trailer number %s" % i, 1)
|
self.logMsg("Successfally added trailer number %s" % i, 1)
|
||||||
# Set "working point" to the movie (last one in playlist)
|
# Set "working point" to the movie (last one in playlist)
|
||||||
API.setChildNumber(playListSize - 1)
|
API.setChildNumber(-1)
|
||||||
|
|
||||||
############### -- ADD MAIN ITEM ONLY FOR HOMESCREEN ###############
|
############### -- ADD MAIN ITEM ONLY FOR HOMESCREEN ###############
|
||||||
|
|
||||||
|
@ -153,7 +148,7 @@ class PlaybackUtils():
|
||||||
# only if there's no playlist first
|
# only if there's no playlist first
|
||||||
self.logMsg("Adding main item to playlist.", 1)
|
self.logMsg("Adding main item to playlist.", 1)
|
||||||
# self.pl.addtoPlaylist(dbid, item['Type'].lower())
|
# self.pl.addtoPlaylist(dbid, item['Type'].lower())
|
||||||
self.pl.addtoPlaylist(dbid, item[0].attrib['type'].lower())
|
self.pl.addtoPlaylist(dbid, item[-1].attrib['type'].lower())
|
||||||
|
|
||||||
# Ensure that additional parts are played after the main item
|
# Ensure that additional parts are played after the main item
|
||||||
currentPosition += 1
|
currentPosition += 1
|
||||||
|
@ -199,7 +194,7 @@ class PlaybackUtils():
|
||||||
|
|
||||||
# For transcoding only, ask for audio/subs pref
|
# For transcoding only, ask for audio/subs pref
|
||||||
if utils.window('emby_%s.playmethod' % playurl) == "Transcode":
|
if utils.window('emby_%s.playmethod' % playurl) == "Transcode":
|
||||||
playurl = playutils.audioSubsPref(playurl)
|
playurl = playutils.audioSubsPref(playurl, child=self.API.getChild())
|
||||||
utils.window('emby_%s.playmethod' % playurl, value="Transcode")
|
utils.window('emby_%s.playmethod' % playurl, value="Transcode")
|
||||||
|
|
||||||
listitem.setPath(playurl)
|
listitem.setPath(playurl)
|
||||||
|
|
|
@ -36,9 +36,10 @@ class PlayUtils():
|
||||||
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
||||||
|
|
||||||
|
|
||||||
def getPlayUrl(self):
|
def getPlayUrl(self, child=0):
|
||||||
|
|
||||||
item = self.item
|
item = self.item
|
||||||
|
self.API.setChildNumber(child)
|
||||||
playurl = None
|
playurl = None
|
||||||
|
|
||||||
# if item['MediaSources'][0]['Protocol'] == "Http":
|
# if item['MediaSources'][0]['Protocol'] == "Http":
|
||||||
|
@ -318,7 +319,8 @@ class PlayUtils():
|
||||||
# max bit rate supported by server (max signed 32bit integer)
|
# max bit rate supported by server (max signed 32bit integer)
|
||||||
return bitrate.get(videoQuality, 2147483)
|
return bitrate.get(videoQuality, 2147483)
|
||||||
|
|
||||||
def audioSubsPref(self, url):
|
def audioSubsPref(self, url, child=0):
|
||||||
|
self.API.setChildNumber(child)
|
||||||
# For transcoding only
|
# For transcoding only
|
||||||
# Present the list of audio to select from
|
# Present the list of audio to select from
|
||||||
audioStreamsList = {}
|
audioStreamsList = {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue