delete the whole video database and the addon_data info

This commit is contained in:
im85288 2015-04-03 10:58:21 +01:00
parent 3cb23b8079
commit 32db5aaa08

View file

@ -50,6 +50,11 @@ def convertEncoding(data):
return data return data
def KodiSQL(): def KodiSQL():
connection = sqlite3.connect(getKodiDBPath())
return connection
def getKodiDBPath():
if xbmc.getInfoLabel("System.BuildVersion").startswith("13"): if xbmc.getInfoLabel("System.BuildVersion").startswith("13"):
#gotham #gotham
dbVersion = "78" dbVersion = "78"
@ -61,10 +66,8 @@ def KodiSQL():
dbVersion = "90" dbVersion = "90"
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos" + dbVersion + ".db") dbPath = xbmc.translatePath("special://userdata/Database/MyVideos" + dbVersion + ".db")
connection = sqlite3.connect(dbPath)
return dbPath
return connection
def checkAuthentication(): def checkAuthentication():
#check authentication #check authentication
@ -166,177 +169,18 @@ def reset():
dialog.ok('Warning', 'Could not stop DB sync, you should try again.') dialog.ok('Warning', 'Could not stop DB sync, you should try again.')
return return
xbmc.sleep(1000) xbmc.sleep(1000)
# clear video database
connection = KodiSQL()
cursor = connection.cursor()
try:
cursor.execute("DROP TABLE episode;")
except:
pass
try:
cursor.execute("DROP TABLE movie;")
except:
pass
try:
cursor.execute("DROP TABLE tvshow;")
except:
pass
try:
cursor.execute("DROP TABLE actors;")
except:
pass
try:
cursor.execute("DROP TABLE actorlinkepisode;")
except:
pass
try:
cursor.execute("DROP TABLE actorlinkmovie;")
except:
pass
try:
cursor.execute("DROP TABLE actorlinktvshow;")
except:
pass
try:
cursor.execute("DROP TABLE art;")
except:
pass
try:
cursor.execute("DROP TABLE artistlinkmusicvideo;")
except:
pass
try:
cursor.execute("DROP TABLE countrylinkmovie;")
except:
pass
try:
cursor.execute("DROP TABLE directorlinkepisode;")
except:
pass
try:
cursor.execute("DROP TABLE directorlinkmovie;")
except:
pass
try:
cursor.execute("DROP TABLE directorlinkmusicvideo;")
except:
pass
try:
cursor.execute("DROP TABLE directorlinktvshow;")
except:
pass
try:
cursor.execute("DROP TABLE files;")
except:
pass
try:
cursor.execute("DROP TABLE genre;")
except:
pass
try:
cursor.execute("DROP TABLE genrelinkmovie;")
except:
pass
try:
cursor.execute("DROP TABLE genrelinkmusicvideo;")
except:
pass
try:
cursor.execute("DROP TABLE genrelinktvshow;")
except:
pass
try:
cursor.execute("DROP TABLE movielinktvshow;")
except:
pass
try:
cursor.execute("DROP TABLE musicvideo;")
except:
pass
try:
cursor.execute("DROP TABLE path;")
except:
pass
try:
cursor.execute("DROP TABLE seasons;")
except:
pass
try:
cursor.execute("DROP TABLE sets;")
except:
pass
try:
cursor.execute("DROP TABLE stacktimes;")
except:
pass
try:
cursor.execute("DROP TABLE streamdetails;")
except:
pass
try:
cursor.execute("DROP TABLE studio;")
except:
pass
try:
cursor.execute("DROP TABLE studiolinkmovie;")
except:
pass
try:
cursor.execute("DROP TABLE studiolinkmusicvideo;")
except:
pass
try:
cursor.execute("DROP TABLE studiolinktvshow;")
except:
pass
try:
cursor.execute("DROP TABLE tag;")
except:
pass
try:
cursor.execute("DROP TABLE taglinks;")
except:
pass
try:
cursor.execute("DROP TABLE tvshowlinkepisode;")
except:
pass
try:
cursor.execute("DROP TABLE tvshowlinkpath;")
except:
pass
try:
cursor.execute("DROP TABLE version;")
except:
pass
try:
cursor.execute("DROP TABLE writerlinkepisode;")
except:
pass
try:
cursor.execute("DROP TABLE writerlinkmovie;")
except:
pass
try: # delete db
connection.commit() os.remove(getKodiDBPath())
logMsg("Emby","Removed tables from kodi database")
finally:
cursor.close()
# check for old library folder and delete if present # remove from addon data directory
addon = xbmcaddon.Addon(id='plugin.video.emby') addon = xbmcaddon.Addon(id='plugin.video.emby')
addondir = xbmc.translatePath(addon.getAddonInfo('profile')) addondir = xbmc.translatePath(addon.getAddonInfo('profile'))
dataPath = os.path.join(addondir,"library" + os.sep) dataPath = os.path.join(addondir + os.sep)
removeDirectory(dataPath) removeDirectory(dataPath)
# remove old entries from sources.xml # remove old entries from sources.xml
# reset addon settings values
addon.setSetting("SyncInstallRunDone", "false")
addon.setSetting("SyncFirstCountsRunDone", "false")
dialog = xbmcgui.Dialog() dialog = xbmcgui.Dialog()
dialog.ok('Emby Reset', 'Reset of Emby has completed, you need to restart.') dialog.ok('Emby Reset', 'Reset of Emby has completed, you need to restart.')
xbmc.executebuiltin("RestartApp") xbmc.executebuiltin("RestartApp")