revert to old method for file access while sorting out the plugin approach

This commit is contained in:
Marcel van der Veldt 2015-05-01 22:14:00 +02:00
parent e77d5c7c53
commit ecd1fad09f
2 changed files with 47 additions and 15 deletions

View File

@ -62,7 +62,7 @@ def getKodiDBPath():
dbVersion = "78" dbVersion = "78"
if xbmc.getInfoLabel("System.BuildVersion").startswith("15"): if xbmc.getInfoLabel("System.BuildVersion").startswith("15"):
#isengard #isengard
dbVersion = "91" dbVersion = "92"
else: else:
#helix #helix
dbVersion = "90" dbVersion = "90"

View File

@ -113,9 +113,21 @@ class WriteKodiDB():
#### ADD OR UPDATE THE FILE AND PATH ########### #### ADD OR UPDATE THE FILE AND PATH ###########
#### NOTE THAT LASTPLAYED AND PLAYCOUNT ARE STORED AT THE FILE ENTRY #### NOTE THAT LASTPLAYED AND PLAYCOUNT ARE STORED AT THE FILE ENTRY
path = "plugin://plugin.video.emby/" path = "plugin://plugin.video.emby/?id=%s&mode=play" % MBitem["Id"]
filename = "plugin://plugin.video.emby/?id=%s&mode=play" % MBitem["Id"] filename = "plugin://plugin.video.emby/?id=%s&mode=play" % MBitem["Id"]
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
playurl = utils.convertEncoding(playurl)
# we need to store both the path and the filename seperately in the kodi db so we split them up
if "\\" in playurl:
filename = playurl.rsplit("\\",1)[-1]
path = playurl.replace(filename,"")
elif "/" in playurl:
filename = playurl.rsplit("/",1)[-1]
path = playurl.replace(filename,"")
#create the path #create the path
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()
@ -227,11 +239,28 @@ class WriteKodiDB():
path = "plugin://plugin.video.emby/tvshows/" + MBitem["Id"] + "/" path = "plugin://plugin.video.emby/tvshows/" + MBitem["Id"] + "/"
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
#make sure that the path always ends with a slash
path = utils.convertEncoding(playurl + "/")
#### ADD THE TV SHOW TO KODI ############## #### ADD THE TV SHOW TO KODI ##############
if showid == None: if showid == None:
#create the tv show 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, strContent, strScraper, noUpdate) values(?, ?, ?, ?, ?)"
cursor.execute(pathsql, (pathid,path,None,None,1))
#create toplevel path as monitored source - needed for things like actors and stuff to work (no clue why) #create toplevel path as monitored source - needed for things like actors and stuff to work (no clue why)
toplevelpath = "plugin://plugin.video.emby/tvshows/" if "\\" in path:
toplevelpathstr = path.rsplit("\\",2)[1]
toplevelpath = path.replace(toplevelpathstr + "\\","")
elif "/" in path:
toplevelpathstr = path.rsplit("/",2)[1]
toplevelpath = path.replace(toplevelpathstr + "/","")
cursor.execute("SELECT idPath as tlpathid FROM path WHERE strPath = ?",(toplevelpath,)) cursor.execute("SELECT idPath as tlpathid FROM path WHERE strPath = ?",(toplevelpath,))
result = cursor.fetchone() result = cursor.fetchone()
if result == None: if result == None:
@ -240,15 +269,7 @@ class WriteKodiDB():
tlpathid = tlpathid + 1 tlpathid = tlpathid + 1
pathsql="insert into path(idPath, strPath, strContent, strScraper, noUpdate) values(?, ?, ?, ?, ?)" pathsql="insert into path(idPath, strPath, strContent, strScraper, noUpdate) values(?, ?, ?, ?, ?)"
cursor.execute(pathsql, (tlpathid,toplevelpath,"tvshows","metadata.local",1)) cursor.execute(pathsql, (tlpathid,toplevelpath,"tvshows","metadata.local",1))
else:
tlpathid = result[0]
#create the tv show 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, strContent, strScraper, noUpdate, idParentPath) values(?, ?, ?, ?, ?, ?)"
cursor.execute(pathsql, (pathid,path,None,None,1,tlpathid))
runtime = int(timeInfo.get('Duration'))*60 runtime = int(timeInfo.get('Duration'))*60
plot = utils.convertEncoding(API().getOverview(MBitem)) plot = utils.convertEncoding(API().getOverview(MBitem))
@ -259,7 +280,7 @@ class WriteKodiDB():
#create the tvshow #create the tvshow
cursor.execute("select coalesce(max(idShow),0) as showid from tvshow") cursor.execute("select coalesce(max(idShow),0) as showid from tvshow")
showid = cursor.fetchone()[0] showid = cursor.fetchone()[0]
showid = pathid + 1 showid = showid + 1
pathsql="insert into tvshow(idShow, c00, c01, c04, c05, c08, c09, c13, c14, c15, embyId) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" pathsql="insert into tvshow(idShow, c00, c01, c04, c05, c08, c09, c13, c14, c15, embyId) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
cursor.execute(pathsql, (showid, title, plot, rating, premieredate, genre, title, mpaa, studio, sorttitle, MBitem["Id"])) cursor.execute(pathsql, (showid, title, plot, rating, premieredate, genre, title, mpaa, studio, sorttitle, MBitem["Id"]))
@ -434,6 +455,18 @@ class WriteKodiDB():
path = "plugin://plugin.video.emby/tvshows/" + MBitem["SeriesId"] + "/" path = "plugin://plugin.video.emby/tvshows/" + MBitem["SeriesId"] + "/"
filename = "plugin://plugin.video.emby/tvshows/" + MBitem["SeriesId"] + "/?id=" + MBitem["Id"] + "&mode=play" filename = "plugin://plugin.video.emby/tvshows/" + MBitem["SeriesId"] + "/?id=" + MBitem["Id"] + "&mode=play"
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
playurl = utils.convertEncoding(playurl)
# we need to store both the path and the filename seperately in the kodi db so we split them up
if "\\" in playurl:
filename = playurl.rsplit("\\",1)[-1]
path = playurl.replace(filename,"")
elif "/" in playurl:
filename = playurl.rsplit("/",1)[-1]
path = playurl.replace(filename,"")
#create the new path - return id if already exists #create the new path - return id if already exists
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()
@ -686,7 +719,6 @@ class WriteKodiDB():
peoplesql="INSERT OR REPLACE into writerlinkepisode(idWriter, idEpisode) values(?, ?)" peoplesql="INSERT OR REPLACE into writerlinkepisode(idWriter, idEpisode) values(?, ?)"
cursor.execute(peoplesql, (actorid,id)) cursor.execute(peoplesql, (actorid,id))
def AddGenresToMedia(self, id, genres, mediatype, cursor): def AddGenresToMedia(self, id, genres, mediatype, cursor):
if genres: if genres: