Force pick first media stream for direct path sync

- Otherwise user would need to choose media stream for every item with
several streams - cumbersome for large libraries with many such items
This commit is contained in:
tomkat83 2016-07-12 20:27:59 +02:00
parent a0b1adbf70
commit 04e31986b5
2 changed files with 20 additions and 11 deletions

View file

@ -1257,22 +1257,29 @@ class API():
"""
return self.item.attrib.get('key')
def getFilePath(self):
def getFilePath(self, forceFirstMediaStream=False):
"""
Returns the direct path to this item, e.g. '\\NAS\movies\movie.mkv'
or None
forceFirstMediaStream=True:
will always use 1st media stream, e.g. when several different
files are present for the same PMS item
"""
try:
res = self.item[self.__getMedia()][self.part].attrib.get('file')
if forceFirstMediaStream is False:
ans = self.item[self.__getMedia()][self.part].attrib['file']
else:
ans = self.item[0][self.part].attrib['file']
except:
res = None
if res is not None:
ans = None
if ans is not None:
try:
res = utils.tryDecode(unquote(res))
ans = utils.tryDecode(unquote(ans))
except UnicodeDecodeError:
# Sometimes, Plex seems to have encoded in latin1
res = unquote(res).decode('latin1')
return res
ans = unquote(ans).decode('latin1')
return ans
def getTVShowPath(self):
"""
@ -2368,7 +2375,9 @@ class API():
self.item[0][0].attrib['key']))
else:
# Native direct paths
path = self.validatePlayurl(self.getFilePath(), 'photo')
path = self.validatePlayurl(
self.getFilePath(forceFirstMediaStream=True),
'photo')
path = utils.tryEncode(path)
metadata = {
'date': self.GetKodiPremierDate(),

View file

@ -411,7 +411,7 @@ class Movies(Items):
doIndirect = not self.directpath
if self.directpath:
# Direct paths is set the Kodi way
playurl = API.getFilePath()
playurl = API.getFilePath(forceFirstMediaStream=True)
if playurl is None:
# Something went wrong, trying to use non-direct paths
doIndirect = True
@ -1302,7 +1302,7 @@ class TVShows(Items):
# GET THE FILE AND PATH #####
doIndirect = not self.directpath
playurl = API.getFilePath()
playurl = API.getFilePath(forceFirstMediaStream=True)
if self.directpath:
# Direct paths is set the Kodi way
if playurl is None:
@ -2060,7 +2060,7 @@ class Music(Items):
doIndirect = not self.directpath
if self.directpath:
# Direct paths is set the Kodi way
playurl = API.getFilePath()
playurl = API.getFilePath(forceFirstMediaStream=True)
if playurl is None:
# Something went wrong, trying to use non-direct paths
doIndirect = True