Fix getting Bit Depth from Plex metadata

- Fixes #98
This commit is contained in:
tomkat83 2016-09-08 15:55:49 +02:00
parent 67ca52a93e
commit affde8bbcb
2 changed files with 12 additions and 8 deletions

View file

@ -1184,7 +1184,7 @@ class API():
self.item = item self.item = item
# which media part in the XML response shall we look at? # which media part in the XML response shall we look at?
self.part = 0 self.part = 0
self.media = 0 self.mediastream = None
self.server = window('pms_server') self.server = window('pms_server')
self.client = clientinfo.ClientInfo() self.client = clientinfo.ClientInfo()
@ -1239,9 +1239,11 @@ class API():
will always use 1st media stream, e.g. when several different will always use 1st media stream, e.g. when several different
files are present for the same PMS item files are present for the same PMS item
""" """
if self.mediastream is None and forceFirstMediaStream is False:
self.getMediastreamNumber()
try: try:
if forceFirstMediaStream is False: if forceFirstMediaStream is False:
ans = self.item[self._getMedia()][self.part].attrib['file'] ans = self.item[self.mediastream][self.part].attrib['file']
else: else:
ans = self.item[0][self.part].attrib['file'] ans = self.item[0][self.part].attrib['file']
except: except:
@ -1697,7 +1699,7 @@ class API():
'aspectratio': self.getDataFromPartOrMedia('aspectratio'), 'aspectratio': self.getDataFromPartOrMedia('aspectratio'),
'bitrate': self.getDataFromPartOrMedia('bitrate'), 'bitrate': self.getDataFromPartOrMedia('bitrate'),
'container': self.getDataFromPartOrMedia('container'), 'container': self.getDataFromPartOrMedia('container'),
'bitDepth': self.getDataFromPartOrMedia('bitDepth') 'bitDepth': self.item[0][self.part][self.mediastream].attrib.get('bitDepth')
} }
def getExtras(self): def getExtras(self):
@ -2170,7 +2172,7 @@ class API():
""" """
return self.item[0].attrib.get('optimizedForStreaming') == '1' return self.item[0].attrib.get('optimizedForStreaming') == '1'
def _getMedia(self): def getMediastreamNumber(self):
""" """
Returns the Media stream as an int (mostly 0). Will let the user choose Returns the Media stream as an int (mostly 0). Will let the user choose
if several media streams are present for a PMS item (if settings are if several media streams are present for a PMS item (if settings are
@ -2199,7 +2201,7 @@ class API():
media = xbmcgui.Dialog().select('Select stream', dialoglist) media = xbmcgui.Dialog().select('Select stream', dialoglist)
else: else:
media = 0 media = 0
self.media = media self.mediastream = media
return media return media
def getTranscodeVideoPath(self, action, quality=None): def getTranscodeVideoPath(self, action, quality=None):
@ -2223,14 +2225,15 @@ class API():
TODO: mediaIndex TODO: mediaIndex
""" """
media_stream = self._getMedia() if self.mediastream is None:
self.getMediastreamNumber()
if quality is None: if quality is None:
quality = {} quality = {}
xargs = self.client.getXArgsDeviceInfo() xargs = self.client.getXArgsDeviceInfo()
# For DirectPlay, path/key of PART is needed # For DirectPlay, path/key of PART is needed
# trailers are 'clip' with PMS xmls # trailers are 'clip' with PMS xmls
if action == "DirectStream": if action == "DirectStream":
path = self.item[media_stream][self.part].attrib['key'] path = self.item[self.mediastream][self.part].attrib['key']
url = self.server + path url = self.server + path
# e.g. Trailers already feature an '?'! # e.g. Trailers already feature an '?'!
if '?' in url: if '?' in url:
@ -2249,7 +2252,7 @@ class API():
'session': self.client.getDeviceId(), 'session': self.client.getDeviceId(),
'fastSeek': 1, 'fastSeek': 1,
'path': path, 'path': path,
'mediaIndex': media_stream, 'mediaIndex': self.mediastream,
'partIndex': self.part, 'partIndex': self.part,
# 'copyts': 1, # 'copyts': 1,
# 'offset': 0, # Resume point # 'offset': 0, # Resume point

View file

@ -38,6 +38,7 @@ class PlayUtils():
playurl is utf-8 encoded! playurl is utf-8 encoded!
""" """
self.API.setPartNumber(partNumber) self.API.setPartNumber(partNumber)
self.API.getMediastreamNumber()
playurl = self.isDirectPlay() playurl = self.isDirectPlay()
if playurl is not None: if playurl is not None: