From 03d99ed0d80eb5add0c19468c9cbe9e7cb1f7955 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sat, 28 Mar 2015 19:04:32 +0100 Subject: [PATCH] use the plugin method for playback when transcoding, use native kodi playback for direct access --- resources/lib/CreateFiles.py | 4 ++++ resources/lib/PlayUtils.py | 9 +++++---- resources/lib/WriteKodiDB.py | 34 +++++++++++++--------------------- resources/settings.xml | 2 +- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/resources/lib/CreateFiles.py b/resources/lib/CreateFiles.py index e05bf84f..30a83bb7 100644 --- a/resources/lib/CreateFiles.py +++ b/resources/lib/CreateFiles.py @@ -63,6 +63,10 @@ class CreateFiles(): host = addon.getSetting('ipaddress') server = host + ":" + port playurl = PlayUtils().getPlayUrl(server, item["Id"], item) + + #do not use direct path for transcoding + if playurl.startswith("http"): + playurl = "plugin://plugin.video.emby/?id=" + item["Id"] + '&mode=play' text_file.writelines(playurl) text_file.close() diff --git a/resources/lib/PlayUtils.py b/resources/lib/PlayUtils.py index 8deff44b..11abde06 100644 --- a/resources/lib/PlayUtils.py +++ b/resources/lib/PlayUtils.py @@ -76,10 +76,11 @@ class PlayUtils(): # Works out if we are direct playing or not def isDirectPlay(self, result): - if (self.fileExists(result) or (result.get("LocationType") == "FileSystem" and self.isNetworkQualitySufficient(result) == True and self.isLocalPath(result) == False)): - return True - else: - return False + # if (self.fileExists(result) or (result.get("LocationType") == "FileSystem" and self.isNetworkQualitySufficient(result) == True and self.isLocalPath(result) == False)): + # return True + # else: + # return False + return False # Works out if the network quality can play directly or if transcoding is needed diff --git a/resources/lib/WriteKodiDB.py b/resources/lib/WriteKodiDB.py index 83304899..d1a21c61 100644 --- a/resources/lib/WriteKodiDB.py +++ b/resources/lib/WriteKodiDB.py @@ -99,6 +99,8 @@ class WriteKodiDB(): #set Filename playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem) + if playurl.startswith("http"): + playurl = "plugin://plugin.video.emby/?id=" + MBitem["Id"] + '&mode=play' if playurl != KodiItem["file"]: self.setKodiFilename(KodiItem["movieid"], playurl, "movie") @@ -432,6 +434,8 @@ class WriteKodiDB(): #set Filename playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem) + if playurl.startswith("http"): + playurl = "plugin://plugin.video.emby/?id=" + MBitem["Id"] + '&mode=play' if playurl != KodiItem["file"]: self.setKodiFilename(KodiItem["episodeid"], playurl, "episode") @@ -890,28 +894,16 @@ class WriteKodiDB(): def setKodiFilename(self, id, filenameAndPath, fileType): #use sqlite to set the filename in DB -- needed to avoid problems with resumepoints etc #todo --> submit PR to kodi team to get this added to the jsonrpc api - + #todo --> extend support for musicvideos filenameAndPath = utils.convertEncoding(filenameAndPath) - - print "set filepath for id " + str(id) - - if not filenameAndPath.startswith("http"): - #assume direct play - if "\\" in filenameAndPath: - filename = filenameAndPath.rsplit("\\",1)[-1] - path = filenameAndPath.replace(filename,"") - elif "/" in filenameAndPath: - filename = filenameAndPath.rsplit("/",1)[-1] - path = filenameAndPath.replace(filename,"") - else: - #assume play from stream ? - filename = filenameAndPath - path = "plugin://plugin.video.emby/" - else: - #assume play from stream - filename = filenameAndPath - path = "plugin://plugin.video.emby/" - + + if "\\" in filenameAndPath: + filename = filenameAndPath.rsplit("\\",1)[-1] + path = filenameAndPath.replace(filename,"") + elif "/" in filenameAndPath: + filename = filenameAndPath.rsplit("/",1)[-1] + path = filenameAndPath.replace(filename,"") + utils.logMsg("MB3 Sync","setting filename in kodi db..." + fileType + ": " + str(id)) xbmc.sleep(sleepVal) connection = utils.KodiSQL() diff --git a/resources/settings.xml b/resources/settings.xml index 0ee1b523..c13c81b9 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -29,7 +29,7 @@ - +