Greatly speed up switch of PMS
This commit is contained in:
parent
ae15030bb5
commit
f31046bed1
3 changed files with 53 additions and 56 deletions
|
@ -1851,10 +1851,6 @@ msgctxt "#39601"
|
||||||
msgid "Could not stop the database from running. Please try again later."
|
msgid "Could not stop the database from running. Please try again later."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#39602"
|
|
||||||
msgid "Remove all cached artwork? (recommended!)"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgctxt "#39603"
|
msgctxt "#39603"
|
||||||
msgid "Reset all PlexKodiConnect Addon settings? (this is usually NOT recommended and unnecessary!)"
|
msgid "Reset all PlexKodiConnect Addon settings? (this is usually NOT recommended and unnecessary!)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -53,11 +53,9 @@ def chooseServer():
|
||||||
if not __LogOut():
|
if not __LogOut():
|
||||||
return
|
return
|
||||||
|
|
||||||
from utils import delete_playlists, delete_nodes
|
from utils import wipe_database
|
||||||
# First remove playlists
|
# Wipe Kodi and Plex database as well as playlists and video nodes
|
||||||
delete_playlists()
|
wipe_database()
|
||||||
# Remove video nodes
|
|
||||||
delete_nodes()
|
|
||||||
|
|
||||||
# Log in again
|
# Log in again
|
||||||
__LogIn()
|
__LogIn()
|
||||||
|
|
|
@ -368,34 +368,14 @@ def create_actor_db_index():
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
def reset():
|
def wipe_database():
|
||||||
"""
|
"""
|
||||||
User navigated to the PKC settings, Advanced, and wants to reset the Kodi
|
Deletes all Plex playlists as well as video nodes, then clears Kodi as well
|
||||||
database and possibly PKC entirely
|
as Plex databases completely.
|
||||||
|
Will also delete all cached artwork.
|
||||||
"""
|
"""
|
||||||
# Are you sure you want to reset your local Kodi database?
|
|
||||||
if not dialog('yesno',
|
|
||||||
heading='{plex} %s ' % language(30132),
|
|
||||||
line1=language(39600)):
|
|
||||||
return
|
|
||||||
|
|
||||||
# first stop any db sync
|
|
||||||
plex_command('STOP_SYNC', 'True')
|
|
||||||
count = 10
|
|
||||||
while window('plex_dbScan') == "true":
|
|
||||||
LOG.debug("Sync is running, will retry: %s...", count)
|
|
||||||
count -= 1
|
|
||||||
if count == 0:
|
|
||||||
# Could not stop the database from running. Please try again later.
|
|
||||||
dialog('ok',
|
|
||||||
heading='{plex} %s' % language(30132),
|
|
||||||
line1=language(39601))
|
|
||||||
return
|
|
||||||
xbmc.sleep(1000)
|
|
||||||
|
|
||||||
# Clean up the playlists
|
# Clean up the playlists
|
||||||
delete_playlists()
|
delete_playlists()
|
||||||
|
|
||||||
# Clean up the video nodes
|
# Clean up the video nodes
|
||||||
delete_nodes()
|
delete_nodes()
|
||||||
|
|
||||||
|
@ -435,36 +415,59 @@ def reset():
|
||||||
tablename = row[0]
|
tablename = row[0]
|
||||||
if tablename != "version":
|
if tablename != "version":
|
||||||
cursor.execute("DELETE FROM %s" % tablename)
|
cursor.execute("DELETE FROM %s" % tablename)
|
||||||
cursor.execute('DROP table IF EXISTS plex')
|
|
||||||
cursor.execute('DROP table IF EXISTS view')
|
|
||||||
connection.commit()
|
connection.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
# Remove all cached artwork? (recommended!)
|
LOG.info("Resetting all cached artwork.")
|
||||||
if dialog('yesno',
|
# Remove all existing textures first
|
||||||
heading='{plex} %s ' % language(30132),
|
path = xbmc.translatePath("special://thumbnails/")
|
||||||
line1=language(39602)):
|
if exists(path):
|
||||||
LOG.info("Resetting all cached artwork.")
|
rmtree(try_decode(path), ignore_errors=True)
|
||||||
# Remove all existing textures first
|
# remove all existing data from texture DB
|
||||||
path = xbmc.translatePath("special://thumbnails/")
|
connection = kodi_sql('texture')
|
||||||
if exists(path):
|
cursor = connection.cursor()
|
||||||
rmtree(try_decode(path), ignore_errors=True)
|
query = 'SELECT tbl_name FROM sqlite_master WHERE type=?'
|
||||||
# remove all existing data from texture DB
|
cursor.execute(query, ("table", ))
|
||||||
connection = kodi_sql('texture')
|
rows = cursor.fetchall()
|
||||||
cursor = connection.cursor()
|
for row in rows:
|
||||||
query = 'SELECT tbl_name FROM sqlite_master WHERE type=?'
|
table_name = row[0]
|
||||||
cursor.execute(query, ("table", ))
|
if table_name != "version":
|
||||||
rows = cursor.fetchall()
|
cursor.execute("DELETE FROM %s" % table_name)
|
||||||
for row in rows:
|
connection.commit()
|
||||||
table_name = row[0]
|
cursor.close()
|
||||||
if table_name != "version":
|
|
||||||
cursor.execute("DELETE FROM %s" % table_name)
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
|
||||||
|
|
||||||
# reset the install run flag
|
# reset the install run flag
|
||||||
settings('SyncInstallRunDone', value="false")
|
settings('SyncInstallRunDone', value="false")
|
||||||
|
|
||||||
|
|
||||||
|
def reset():
|
||||||
|
"""
|
||||||
|
User navigated to the PKC settings, Advanced, and wants to reset the Kodi
|
||||||
|
database and possibly PKC entirely
|
||||||
|
"""
|
||||||
|
# Are you sure you want to reset your local Kodi database?
|
||||||
|
if not dialog('yesno',
|
||||||
|
heading='{plex} %s ' % language(30132),
|
||||||
|
line1=language(39600)):
|
||||||
|
return
|
||||||
|
|
||||||
|
# first stop any db sync
|
||||||
|
plex_command('STOP_SYNC', 'True')
|
||||||
|
count = 10
|
||||||
|
while window('plex_dbScan') == "true":
|
||||||
|
LOG.debug("Sync is running, will retry: %s...", count)
|
||||||
|
count -= 1
|
||||||
|
if count == 0:
|
||||||
|
# Could not stop the database from running. Please try again later.
|
||||||
|
dialog('ok',
|
||||||
|
heading='{plex} %s' % language(30132),
|
||||||
|
line1=language(39601))
|
||||||
|
return
|
||||||
|
xbmc.sleep(1000)
|
||||||
|
|
||||||
|
# Wipe everything
|
||||||
|
wipe_database()
|
||||||
|
|
||||||
# Reset all PlexKodiConnect Addon settings? (this is usually NOT
|
# Reset all PlexKodiConnect Addon settings? (this is usually NOT
|
||||||
# recommended and unnecessary!)
|
# recommended and unnecessary!)
|
||||||
if dialog('yesno',
|
if dialog('yesno',
|
||||||
|
|
Loading…
Reference in a new issue