From bad32e90ab7a3afc9933bdf30578ca9daf83f8b5 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 25 Feb 2018 18:15:17 +0100 Subject: [PATCH] Delete genres in Kodi DB --- resources/lib/itemtypes.py | 2 ++ resources/lib/kodidb_functions.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 7d9aa578..bc750fc9 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -482,6 +482,7 @@ class Movies(Items): if kodi_type == v.KODI_TYPE_MOVIE: self.kodi_db.delete_countries(kodi_id, kodi_type) self.kodi_db.delete_people(kodi_id, kodi_type) + self.kodi_db.delete_genre(kodi_id, kodi_type) # Delete kodi movie and file kodicursor.execute("DELETE FROM movie WHERE idMovie = ?", (kodi_id,)) @@ -1205,6 +1206,7 @@ class TVShows(Items): Remove a TV show, and only the show, no seasons or episodes """ kodicursor = self.kodicursor + self.kodi_db.delete_genre(kodi_id, v.KODI_TYPE_SHOW) self.artwork.deleteArtwork(kodi_id, v.KODI_TYPE_SHOW, kodicursor) kodicursor.execute("DELETE FROM tvshow WHERE idShow = ?", (kodi_id,)) if v.KODIVERSION >= 17: diff --git a/resources/lib/kodidb_functions.py b/resources/lib/kodidb_functions.py index 0007fc9e..02d5e1e9 100644 --- a/resources/lib/kodidb_functions.py +++ b/resources/lib/kodidb_functions.py @@ -506,6 +506,16 @@ class KodiDBMethods(object): ''' self.cursor.execute(query, (genre_id, kodi_id, kodi_type)) + def delete_genre(self, kodi_id, kodi_type): + """ + Removes the genre links as well as orphaned genres from the Kodi DB + """ + self._delete_from_link_and_table(kodi_id, + kodi_type, + 'genre_link', + 'genre', + 'genre_id') + def addStudios(self, kodiid, studios, mediatype): for studio in studios: query = ' '.join((