diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index 26acab11..61155ee4 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -1078,6 +1078,15 @@ class LibrarySync(threading.Thread): # Library sync if not startupComplete: + + # Verify the database for videos + videodb = utils.getKodiVideoDBPath() + if not xbmcvfs.exists(videodb): + # Database does not exists. + self.logMsg("The current Kodi version is incompatible with the Emby for Kodi add-on. Please visit here, to see currently supported Kodi versions: https://github.com/MediaBrowser/Emby.Kodi/wiki", 0) + xbmcgui.Dialog().ok("Emby Warning", "Cancelling the database syncing process. Current Kodi version: %s is unsupported. Please verify your logs for more info." % xbmc.getInfoLabel('System.BuildVersion')) + break + # Run full sync self.logMsg("DB Version: " + utils.settings("dbCreatedWithVersion"), 0) self.logMsg("Doing_Db_Sync: syncDatabase (Started)", 1) diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py index b65d56d4..49c479f2 100644 --- a/resources/lib/Utils.py +++ b/resources/lib/Utils.py @@ -56,59 +56,44 @@ def KodiSQL(type="video"): if type == "music": dbPath = getKodiMusicDBPath() elif type == "texture": - dbPath = xbmc.translatePath("special://database/Textures13.db") + dbPath = xbmc.translatePath("special://database/Textures13.db").decode('utf-8') else: dbPath = getKodiVideoDBPath() connection = sqlite3.connect(dbPath) - return connection def getKodiVideoDBPath(): - kodibuild = xbmc.getInfoLabel("System.BuildVersion") + kodibuild = xbmc.getInfoLabel('System.BuildVersion')[:2] + dbVersion = { - if kodibuild.startswith("13"): - # Gotham - dbVersion = "78" - elif kodibuild.startswith("14"): - # Helix - dbVersion = "90" - elif kodibuild.startswith("15"): - # Isengard - dbVersion = "93" - elif kodibuild.startswith("16"): - # Jarvis - dbVersion = "99" - else: - # Not a compatible build - xbmc.log("This Kodi version is incompatible. Current version: %s" % kodibuild) + "13": 78, # Gotham + "14": 90, # Helix + "15": 93, # Isengard + "16": 99 # Jarvis + } - dbPath = xbmc.translatePath("special://profile/Database/MyVideos" + dbVersion + ".db") - - return dbPath + dbPath = xbmc.translatePath( + "special://database/MyVideos%s.db" + % dbVersion.get(kodibuild, "")).decode('utf-8') + return dbPath def getKodiMusicDBPath(): - if xbmc.getInfoLabel("System.BuildVersion").startswith("13"): - #gotham - dbVersion = "46" - elif xbmc.getInfoLabel("System.BuildVersion").startswith("14"): - #helix - dbVersion = "48" - elif xbmc.getInfoLabel("System.BuildVersion").startswith("15"): - #isengard - dbVersion = "52" - elif xbmc.getInfoLabel("System.BuildVersion").startswith("16"): - #jarvis - dbVersion = "55" - else: - # Not a compatible build - xbmc.log("This Kodi version is incompatible. Current version: %s" % kodibuild) - - dbPath = xbmc.translatePath("special://profile/Database/MyMusic" + dbVersion + ".db") - - return dbPath + kodibuild = xbmc.getInfoLabel('System.BuildVersion')[:2] + dbVersion = { + + "13": 46, # Gotham + "14": 48, # Helix + "15": 52, # Isengard + "16": 55 # Jarvis + } + + dbPath = xbmc.translatePath( + "special://database/MyMusic%s.db" + % dbVersion.get(kodibuild, "")).decode('utf-8') + return dbPath def prettifyXml(elem): rough_string = etree.tostring(elem, "utf-8")