fix for directplay

This commit is contained in:
Marcel van der Veldt 2015-03-28 18:36:14 +01:00
parent eccfaf983f
commit 7493e57fcb
1 changed files with 32 additions and 20 deletions

View File

@ -891,36 +891,48 @@ class WriteKodiDB():
#use sqlite to set the filename in DB -- needed to avoid problems with resumepoints etc #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 --> submit PR to kodi team to get this added to the jsonrpc api
print "set filepath for id " + str(id) + " - " + filenameAndPath filenameAndPath = utils.convertEncoding(filenameAndPath)
print "set filepath for id " + str(id)
if not filenameAndPath.startswith("http"):
if "\\" in filenameAndPath: #assume direct play
filename = filenameAndPath.rsplit("\\",1)[-1] if "\\" in filenameAndPath:
path = filenameAndPath.replace(filename,"") filename = filenameAndPath.rsplit("\\",1)[-1]
elif "/" in filenameAndPath: path = filenameAndPath.replace(filename,"")
filename = filenameAndPath.rsplit("/",1)[-1] elif "/" in filenameAndPath:
path = filenameAndPath.replace(filename,"") filename = filenameAndPath.rsplit("/",1)[-1]
path = filenameAndPath.replace(filename,"")
else:
#assume play from stream ?
filename = filenameAndPath
path = "plugin://plugin.video.emby/"
else: else:
#assume play from stream
filename = filenameAndPath filename = filenameAndPath
path = None path = "plugin://plugin.video.emby/"
utils.logMsg("MB3 Sync","setting filename in kodi db..." + fileType + ": " + str(id)) utils.logMsg("MB3 Sync","setting filename in kodi db..." + fileType + ": " + str(id))
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)
connection = utils.KodiSQL() connection = utils.KodiSQL()
cursor = connection.cursor( ) cursor = connection.cursor( )
if path != None: cursor.execute("SELECT idPath as pathid FROM path WHERE strPath = ?",(path,))
cursor.execute("SELECT idPath as pathid FROM path WHERE strPath = ?",(path,)) result = cursor.fetchone()
result = cursor.fetchone() if result != None:
if result != None: pathid = result[0]
pathid = result[0] if result == None:
if result == None: cursor.execute("select coalesce(max(idPath),0) as pathid from path")
cursor.execute("select coalesce(max(idPath),0) as pathid from path") pathid = cursor.fetchone()[0]
pathid = cursor.fetchone()[0] pathid = pathid + 1
pathid = pathid + 1 pathsql="insert into path(idPath, strPath) values(?, ?)"
pathsql="insert into path(idPath, strPath) values(?, ?)" cursor.execute(pathsql, (pathid,path))
cursor.execute(pathsql, (pathid,path))
cursor.execute("select coalesce(max(idPath),0) as pathid from path")
pathid = cursor.fetchone()[0]
pathid = pathid + 1
pathsql="insert into path(idPath, strPath) values(?, ?)"
cursor.execute(pathsql, (pathid,path))
if fileType == "episode": if fileType == "episode":
cursor.execute("SELECT idFile as fileidid FROM episode WHERE idEpisode = ?",(id,)) cursor.execute("SELECT idFile as fileidid FROM episode WHERE idEpisode = ?",(id,))