Delete all synced playlists on PKC (database) reset

This commit is contained in:
Croneter 2018-05-02 19:13:56 +02:00
parent 5b4ed1d6a6
commit 0c3db3e2f8

View file

@ -448,6 +448,11 @@ def wipe_database():
LOG.info("Resetting the Plex database.")
connection = kodi_sql('plex')
cursor = connection.cursor()
# First get the paths to all synced playlists
playlist_paths = []
cursor.execute('SELECT kodi_path FROM playlists')
for entry in cursor.fetchall():
playlist_paths.append(entry[0])
cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"')
rows = cursor.fetchall()
for row in rows:
@ -457,6 +462,13 @@ def wipe_database():
connection.commit()
cursor.close()
# Delete all synced playlists
for path in playlist_paths:
try:
os.remove(path)
except (OSError, IOError):
pass
LOG.info("Resetting all cached artwork.")
# Remove all existing textures first
path = xbmc.translatePath("special://thumbnails/")