From 6b6f77dbffeb5af7af9fae98d4a1478c07ef5e86 Mon Sep 17 00:00:00 2001 From: im85288 Date: Thu, 2 Apr 2015 20:47:06 +0100 Subject: [PATCH] added reset settings - still needs a bit of work --- default.py | 18 +++-- resources/lib/Utils.py | 177 ++++++++++++++++++++++++++++++++++++++++- resources/settings.xml | 35 +++----- 3 files changed, 197 insertions(+), 33 deletions(-) diff --git a/default.py b/default.py index ea062d05..300619d7 100644 --- a/default.py +++ b/default.py @@ -17,15 +17,19 @@ WINDOW = xbmcgui.Window( 10000 ) import Utils as utils from PlaybackUtils import PlaybackUtils -# get the actions... -params=utils.get_params(sys.argv[2]) +try: + params=utils.get_params(sys.argv[2]) + mode = params.get('mode',"") + id = params.get('id',"") +except: + params={} + mode=None + id=None -mode = params.get('mode',"") -id = params.get('id',"") - -if mode == "play": +if mode != None and mode == "play": PlaybackUtils().PLAY(id) - +elif sys.argv[1] == "reset": + utils.reset() else: xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)') diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py index 0ad9acad..727c311e 100644 --- a/resources/lib/Utils.py +++ b/resources/lib/Utils.py @@ -72,7 +72,7 @@ def checkAuthentication(): try: downloadUtils.authenticate() except Exception, e: - logMsg("MB3 Syncer authentication failed",e) + logMsg("Emby authentication failed",e) pass def prettifyXml(elem): @@ -148,3 +148,178 @@ def removeDirectory(path): xbmcvfs.delete(os.path.join(path,file)) xbmcvfs.rmdir(path) + +def reset(): + # 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: + connection.commit() + logMsg("Emby","Removed tables from kodi database") + finally: + cursor.close() + + # check for old library folder and delete if present + addon = xbmcaddon.Addon(id='plugin.video.emby') + addondir = xbmc.translatePath(addon.getAddonInfo('profile')) + dataPath = os.path.join(addondir,"library" + os.sep) + removeDirectory(dataPath) + + # remove old entries from sources.xml + + # reset addon settings values + addon.setSetting("SyncInstallRunDone", "false") + addon.setSetting("SyncFirstCountsRunDone", "false") + + dialog = xbmcgui.Dialog() + dialog.ok('Emby Reset', 'Reset of Emby has completed, please restart.') + diff --git a/resources/settings.xml b/resources/settings.xml index ffd37be1..611237bb 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -1,47 +1,32 @@ - - - + + - - - + - - - + - - + + - - - - - - + + + - - + \ No newline at end of file