Make sure emby tables exists before proceeding

This commit is contained in:
angelblue05 2016-10-20 01:47:42 -05:00
parent 071a4bde9b
commit 6db7972301

View file

@ -232,20 +232,6 @@ class LibrarySync(threading.Thread):
# Add sources
utils.sourcesXML()
embyconn = utils.kodiSQL('emby')
embycursor = embyconn.cursor()
# Create the tables for the emby database
# emby, view, version
embycursor.execute(
"""CREATE TABLE IF NOT EXISTS emby(
emby_id TEXT UNIQUE, media_folder TEXT, emby_type TEXT, media_type TEXT, kodi_id INTEGER,
kodi_fileid INTEGER, kodi_pathid INTEGER, parent_id INTEGER, checksum INTEGER)""")
embycursor.execute(
"""CREATE TABLE IF NOT EXISTS view(
view_id TEXT UNIQUE, view_name TEXT, media_type TEXT, kodi_tagid INTEGER)""")
embycursor.execute("CREATE TABLE IF NOT EXISTS version(idVersion TEXT)")
embyconn.commit()
# content sync: movies, tvshows, musicvideos, music
kodiconn = utils.kodiSQL('video')
kodicursor = kodiconn.cursor()
@ -854,6 +840,23 @@ class LibrarySync(threading.Thread):
# Database out of date.
return False
def _verify_emby_database(cls):
# Create the tables for the emby database
conn = utils.kodiSQL('emby')
cursor = conn.cursor()
# emby, view, version
cursor.execute(
"""CREATE TABLE IF NOT EXISTS emby(
emby_id TEXT UNIQUE, media_folder TEXT, emby_type TEXT, media_type TEXT,
kodi_id INTEGER, kodi_fileid INTEGER, kodi_pathid INTEGER, parent_id INTEGER,
checksum INTEGER)""")
cursor.execute(
"""CREATE TABLE IF NOT EXISTS view(
view_id TEXT UNIQUE, view_name TEXT, media_type TEXT, kodi_tagid INTEGER)""")
cursor.execute("CREATE TABLE IF NOT EXISTS version(idVersion TEXT)")
conn.commit()
def run(self):
try:
@ -885,6 +888,9 @@ class LibrarySync(threading.Thread):
log.warn("---===### Starting LibrarySync ###===---")
# Verify database structure, otherwise create it.
self._verify_emby_database()
while not self.monitor.abortRequested():
# In the event the server goes offline