Link parent paths in Kodi video DB
- Should speed up On Deck video node
This commit is contained in:
parent
97c261bc4d
commit
07ed22e44a
2 changed files with 41 additions and 6 deletions
|
@ -1040,6 +1040,8 @@ class TVShows(Items):
|
||||||
toplevelpath = "plugin://plugin.video.plexkodiconnect.tvshows/"
|
toplevelpath = "plugin://plugin.video.plexkodiconnect.tvshows/"
|
||||||
path = "%s%s/" % (toplevelpath, itemid)
|
path = "%s%s/" % (toplevelpath, itemid)
|
||||||
|
|
||||||
|
# Add top path
|
||||||
|
toppathid = kodi_db.addPath(toplevelpath)
|
||||||
# UPDATE THE TVSHOW #####
|
# UPDATE THE TVSHOW #####
|
||||||
if update_item:
|
if update_item:
|
||||||
self.logMsg("UPDATE tvshow itemid: %s - Title: %s" % (itemid, title), 1)
|
self.logMsg("UPDATE tvshow itemid: %s - Title: %s" % (itemid, title), 1)
|
||||||
|
@ -1062,8 +1064,6 @@ class TVShows(Items):
|
||||||
else:
|
else:
|
||||||
self.logMsg("ADD tvshow itemid: %s - Title: %s" % (itemid, title), 1)
|
self.logMsg("ADD tvshow itemid: %s - Title: %s" % (itemid, title), 1)
|
||||||
|
|
||||||
# Add top path
|
|
||||||
toppathid = kodi_db.addPath(toplevelpath)
|
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
"UPDATE path",
|
"UPDATE path",
|
||||||
|
@ -1098,10 +1098,11 @@ class TVShows(Items):
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
"UPDATE path",
|
"UPDATE path",
|
||||||
"SET strPath = ?, strContent = ?, strScraper = ?, noUpdate = ?",
|
"SET strPath = ?, strContent = ?, strScraper = ?, noUpdate = ?, ",
|
||||||
|
"idParentPath = ?"
|
||||||
"WHERE idPath = ?"
|
"WHERE idPath = ?"
|
||||||
))
|
))
|
||||||
kodicursor.execute(query, (path, None, None, 1, pathid))
|
kodicursor.execute(query, (path, None, None, 1, toppathid, pathid))
|
||||||
|
|
||||||
# Process cast
|
# Process cast
|
||||||
people = API.getPeopleList()
|
people = API.getPeopleList()
|
||||||
|
@ -1324,6 +1325,7 @@ class TVShows(Items):
|
||||||
# Network share
|
# Network share
|
||||||
filename = playurl.rsplit("/", 1)[1]
|
filename = playurl.rsplit("/", 1)[1]
|
||||||
path = playurl.replace(filename, "")
|
path = playurl.replace(filename, "")
|
||||||
|
parentPathId = kodi_db.getParentPathId(path)
|
||||||
if doIndirect:
|
if doIndirect:
|
||||||
# Set plugin path and media flags using real filename
|
# Set plugin path and media flags using real filename
|
||||||
if playurl is not None:
|
if playurl is not None:
|
||||||
|
@ -1341,6 +1343,8 @@ class TVShows(Items):
|
||||||
'mode': "play"
|
'mode': "play"
|
||||||
}
|
}
|
||||||
filename = "%s?%s" % (path, urllib.urlencode(params))
|
filename = "%s?%s" % (path, urllib.urlencode(params))
|
||||||
|
parentPathId = kodi_db.addPath(
|
||||||
|
'plugin://plugin.video.plexkodiconnect.tvshows/')
|
||||||
|
|
||||||
# UPDATE THE EPISODE #####
|
# UPDATE THE EPISODE #####
|
||||||
if update_item:
|
if update_item:
|
||||||
|
@ -1421,10 +1425,11 @@ class TVShows(Items):
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
"UPDATE path",
|
"UPDATE path",
|
||||||
"SET strPath = ?, strContent = ?, strScraper = ?, noUpdate = ?",
|
"SET strPath = ?, strContent = ?, strScraper = ?, noUpdate = ?, ",
|
||||||
|
"idParentPath = ?"
|
||||||
"WHERE idPath = ?"
|
"WHERE idPath = ?"
|
||||||
))
|
))
|
||||||
kodicursor.execute(query, (path, None, None, 1, pathid))
|
kodicursor.execute(query, (path, None, None, 1, parentPathId, pathid))
|
||||||
# Update the file
|
# Update the file
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
|
from ntpath import dirname
|
||||||
|
|
||||||
import artwork
|
import artwork
|
||||||
import clientinfo
|
import clientinfo
|
||||||
|
@ -66,6 +67,35 @@ class Kodidb_Functions():
|
||||||
'metadata.local',
|
'metadata.local',
|
||||||
'plugin://plugin.video.plexkodiconnect.movies%%'))
|
'plugin://plugin.video.plexkodiconnect.movies%%'))
|
||||||
|
|
||||||
|
def getParentPathId(self, path):
|
||||||
|
"""
|
||||||
|
Video DB: Adds all subdirectories to SQL path while setting a "trail"
|
||||||
|
of parentPathId
|
||||||
|
"""
|
||||||
|
if "\\" in path:
|
||||||
|
# Local path
|
||||||
|
parentpath = "%s\\" % dirname(dirname(path))
|
||||||
|
else:
|
||||||
|
# Network path
|
||||||
|
parentpath = "%s/" % dirname(dirname(path))
|
||||||
|
pathid = self.getPath(parentpath)
|
||||||
|
if pathid is None:
|
||||||
|
self.cursor.execute("select coalesce(max(idPath),0) from path")
|
||||||
|
pathid = self.cursor.fetchone()[0] + 1
|
||||||
|
query = ' '.join((
|
||||||
|
"INSERT INTO path(idPath, strPath)",
|
||||||
|
"VALUES (?, ?)"
|
||||||
|
))
|
||||||
|
self.cursor.execute(query, (pathid, parentpath))
|
||||||
|
parentPathid = self.getParentPathId(parentpath)
|
||||||
|
query = ' '.join((
|
||||||
|
"UPDATE path",
|
||||||
|
"SET idParentPath = ?",
|
||||||
|
"WHERE idPath = ?"
|
||||||
|
))
|
||||||
|
self.cursor.execute(query, (parentPathid, pathid))
|
||||||
|
return pathid
|
||||||
|
|
||||||
def addPath(self, path, strHash=None):
|
def addPath(self, path, strHash=None):
|
||||||
# SQL won't return existing paths otherwise
|
# SQL won't return existing paths otherwise
|
||||||
if path is None:
|
if path is None:
|
||||||
|
|
Loading…
Reference in a new issue