Correctly set-up paths table

This commit is contained in:
croneter 2018-02-20 10:19:11 +01:00
parent fe6ccad959
commit 0173129ffc
2 changed files with 67 additions and 19 deletions

View file

@ -44,7 +44,7 @@ class Kodidb_Functions():
self.cursor = cursor
self.artwork = artwork.Artwork()
def pathHack(self):
def setup_path_table(self):
"""
Use with Kodi video DB
@ -53,15 +53,69 @@ class Kodidb_Functions():
For some reason, Kodi ignores this if done via itemtypes while e.g.
adding or updating items. (addPath method does NOT work)
"""
query = ' '.join((
"UPDATE path",
"SET strContent = ?, strScraper = ?",
"WHERE strPath LIKE ?"
))
self.cursor.execute(
query, ('movies',
'metadata.local',
'plugin://plugin.video.plexkodiconnect/movies%%'))
root_path_id = self.getPath('plugin://%s/' % v.ADDON_ID)
if root_path_id is not None:
return
# add the very root plugin://plugin.video.plexkodiconnect to paths
self.cursor.execute("select coalesce(max(idPath),0) from path")
root_path_id = self.cursor.fetchone()[0] + 1
query = '''
INSERT INTO path(idPath,
strPath,
useFolderNames,
noUpdate,
exclude)
VALUES (?, ?, ?, ?, ?)
'''
self.cursor.execute(query, (root_path_id,
'plugin://%s/' % v.ADDON_ID,
False,
True,
True))
# Now add the root folders for movies
self.cursor.execute("select coalesce(max(idPath),0) from path")
path_id = self.cursor.fetchone()[0] + 1
query = '''
INSERT INTO path(idPath,
strPath,
strContent,
strScraper,
useFolderNames,
noUpdate,
exclude,
idParentPath)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
'''
self.cursor.execute(query, (path_id,
'plugin://%s/movies/' % v.ADDON_ID,
'movies',
'metadata.local',
False,
True,
True,
root_path_id))
# And TV shows
self.cursor.execute("select coalesce(max(idPath),0) from path")
path_id = self.cursor.fetchone()[0] + 1
query = '''
INSERT INTO path(idPath,
strPath,
strContent,
strScraper,
useFolderNames,
noUpdate,
exclude,
idParentPath)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
'''
self.cursor.execute(query, (path_id,
'plugin://%s/tvshows/' % v.ADDON_ID,
'tvshows',
'metadata.local',
False,
True,
True,
root_path_id))
def getParentPathId(self, path):
"""

View file

@ -249,6 +249,9 @@ class LibrarySync(Thread):
return False
# Delete all existing resume points first
with kodidb.GetKodiDB('video') as kodi_db:
# Setup the paths for addon-paths (even when using direct paths)
kodi_db.setup_path_table()
# Delete all resume points because we'll get new ones
kodi_db.delete_all_playstates()
process = {
@ -280,15 +283,6 @@ class LibrarySync(Thread):
if state.PMS_STATUS not in ('401', 'Auth'):
# Plex server had too much and returned ERROR
dialog('ok', heading='{plex}', line1=lang(39409))
# Path hack, so Kodis Information screen works
with kodidb.GetKodiDB('video') as kodi_db:
try:
kodi_db.pathHack()
log.info('Path hack successful')
except Exception as e:
# Empty movies, tv shows?
log.error('Path hack failed with error message: %s' % str(e))
return True
def processView(self, folderItem, kodi_db, plex_db, totalnodes):