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.cursor = cursor
self.artwork = artwork.Artwork() self.artwork = artwork.Artwork()
def pathHack(self): def setup_path_table(self):
""" """
Use with Kodi video DB 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. For some reason, Kodi ignores this if done via itemtypes while e.g.
adding or updating items. (addPath method does NOT work) adding or updating items. (addPath method does NOT work)
""" """
query = ' '.join(( root_path_id = self.getPath('plugin://%s/' % v.ADDON_ID)
"UPDATE path", if root_path_id is not None:
"SET strContent = ?, strScraper = ?", return
"WHERE strPath LIKE ?" # add the very root plugin://plugin.video.plexkodiconnect to paths
)) self.cursor.execute("select coalesce(max(idPath),0) from path")
self.cursor.execute( root_path_id = self.cursor.fetchone()[0] + 1
query, ('movies', query = '''
'metadata.local', INSERT INTO path(idPath,
'plugin://plugin.video.plexkodiconnect/movies%%')) 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): def getParentPathId(self, path):
""" """

View file

@ -249,6 +249,9 @@ class LibrarySync(Thread):
return False return False
# Delete all existing resume points first # Delete all existing resume points first
with kodidb.GetKodiDB('video') as kodi_db: 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() kodi_db.delete_all_playstates()
process = { process = {
@ -280,15 +283,6 @@ class LibrarySync(Thread):
if state.PMS_STATUS not in ('401', 'Auth'): if state.PMS_STATUS not in ('401', 'Auth'):
# Plex server had too much and returned ERROR # Plex server had too much and returned ERROR
dialog('ok', heading='{plex}', line1=lang(39409)) 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 return True
def processView(self, folderItem, kodi_db, plex_db, totalnodes): def processView(self, folderItem, kodi_db, plex_db, totalnodes):