From bb2f4601f53857f0b67ae2972130d23864a3480a Mon Sep 17 00:00:00 2001 From: croneter Date: Fri, 16 Mar 2018 07:52:49 +0100 Subject: [PATCH] Clean Kodi DB more thoroughly after playback start via PMS --- resources/lib/kodidb_functions.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/lib/kodidb_functions.py b/resources/lib/kodidb_functions.py index b14a94ff..f0db9d5a 100644 --- a/resources/lib/kodidb_functions.py +++ b/resources/lib/kodidb_functions.py @@ -210,7 +210,18 @@ class KodiDBMethods(object): but without a dateAdded entry. This method cleans up all file entries without a dateAdded entry - to be called after playback has ended. """ + self.cursor.execute('SELECT idFile FROM files WHERE dateAdded IS NULL') + files = self.cursor.fetchall() self.cursor.execute('DELETE FROM files where dateAdded IS NULL') + for file in files: + self.cursor.execute('DELETE FROM bookmark WHERE idFile = ?', + (file[0],)) + self.cursor.execute('DELETE FROM settings WHERE idFile = ?', + (file[0],)) + self.cursor.execute('DELETE FROM streamdetails WHERE idFile = ?', + (file[0],)) + self.cursor.execute('DELETE FROM stacktimes WHERE idFile = ?', + (file[0],)) def remove_file(self, file_id): """