From 725132131c894c83e873cacb7b668e7dc687908f Mon Sep 17 00:00:00 2001 From: croneter Date: Mon, 26 Feb 2018 09:18:44 +0100 Subject: [PATCH] Delete streamdetails from Kodi DB --- resources/lib/itemtypes.py | 6 ++++-- resources/lib/kodidb_functions.py | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 31fca00b..36d563e7 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -442,7 +442,7 @@ class Movies(Items): # Process artwork artwork.addArtwork(api.artwork(), movieid, "movie", kodicursor) # Process stream details - self.kodi_db.addStreams(fileid, api.mediastreams(), runtime) + self.kodi_db.modify_streams(fileid, api.mediastreams(), runtime) # Process studios self.kodi_db.addStudios(movieid, studios, "movie") # Process tags: view, Plex collection tags @@ -486,6 +486,7 @@ class Movies(Items): self.kodi_db.delete_genre(kodi_id, kodi_type) self.kodi_db.delete_studios(kodi_id, kodi_type) self.kodi_db.delete_tags(kodi_id, kodi_type) + self.kodi_db.modify_streams(file_id) # Delete kodi movie and file kodicursor.execute("DELETE FROM movie WHERE idMovie = ?", (kodi_id,)) @@ -1091,7 +1092,7 @@ class TVShows(Items): # Process stream details streams = api.mediastreams() - self.kodi_db.addStreams(fileid, streams, runtime) + self.kodi_db.modify_streams(fileid, streams, runtime) # Process playstates self.kodi_db.addPlaystate(fileid, resume, @@ -1237,6 +1238,7 @@ class TVShows(Items): """ kodicursor = self.kodicursor self.kodi_db.delete_people(kodi_id, v.KODI_TYPE_EPISODE) + self.kodi_db.modify_streams(fileid) self.artwork.deleteArtwork(kodi_id, "episode", kodicursor) kodicursor.execute("DELETE FROM episode WHERE idEpisode = ?", (kodi_id,)) diff --git a/resources/lib/kodidb_functions.py b/resources/lib/kodidb_functions.py index f77a09e8..08c43a79 100644 --- a/resources/lib/kodidb_functions.py +++ b/resources/lib/kodidb_functions.py @@ -558,8 +558,11 @@ class KodiDBMethods(object): 'studio', 'studio_id') - def addStreams(self, fileid, streamdetails, runtime): - + def modify_streams(self, fileid, streamdetails=None, runtime=None): + """ + Leave streamdetails and runtime empty to delete all stream entries for + fileid + """ # First remove any existing entries self.cursor.execute("DELETE FROM streamdetails WHERE idFile = ?", (fileid,)) if streamdetails: