diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 784cb42f..b1e14638 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -6,6 +6,7 @@ import cProfile import inspect import pstats import sqlite3 +import os from datetime import datetime, time import time import unicodedata @@ -144,7 +145,7 @@ def reset(): deleteNodes() # Wipe the kodi databases - logMsg("EMBY", "Resetting the Kodi video database.") + logMsg("EMBY", "Resetting the Kodi video database.", 0) connection = kodiSQL('video') cursor = connection.cursor() cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"') @@ -170,7 +171,7 @@ def reset(): cursor.close() # Wipe the emby database - logMsg("EMBY", "Resetting the Emby database.") + logMsg("EMBY", "Resetting the Emby database.", 0) connection = kodiSQL('emby') cursor = connection.cursor() cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"') @@ -179,15 +180,45 @@ def reset(): tablename = row[0] if tablename != "version": cursor.execute("DELETE FROM " + tablename) + cursor.execute('DROP table IF EXISTS emby') + cursor.execute('DROP table IF EXISTS view') connection.commit() cursor.close() + + # Offer to wipe cached thumbnails + resp = dialog.yesno("Warning", "Removed all cached artwork?") + if resp: + logMsg("EMBY", "Resetting all cached artwork.", 0) + # Remove all existing textures first + path = xbmc.translatePath("special://thumbnails/").decode('utf-8') + if xbmcvfs.exists(path): + allDirs, allFiles = xbmcvfs.listdir(path) + for dir in allDirs: + allDirs, allFiles = xbmcvfs.listdir(path+dir) + for file in allFiles: + if os.path.supports_unicode_filenames: + xbmcvfs.delete(os.path.join(path+dir.decode('utf-8'),file.decode('utf-8'))) + else: + xbmcvfs.delete(os.path.join(path.encode('utf-8')+dir,file)) + + # remove all existing data from texture DB + connection = kodiSQL('texture') + cursor = connection.cursor() + cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"') + rows = cursor.fetchall() + for row in rows: + tableName = row[0] + if(tableName != "version"): + cursor.execute("DELETE FROM " + tableName) + connection.commit() + cursor.close() # reset the install run flag settings('SyncInstallRunDone', value="false") # Remove emby info resp = dialog.yesno("Warning", "Reset all Emby Addon settings?") - if resp == 1: + if resp: # Delete the settings addon = xbmcaddon.Addon() addondir = xbmc.translatePath(addon.getAddonInfo('profile')).decode('utf-8')