From a9bed6a3f840b4b34f435289a49116e32b8ccfb7 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 25 Nov 2018 17:21:41 +0100 Subject: [PATCH] Fix removal of movies --- resources/lib/itemtypes/movies.py | 68 +++++++++++++++---------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/resources/lib/itemtypes/movies.py b/resources/lib/itemtypes/movies.py index 7f52ae2f..17f80998 100644 --- a/resources/lib/itemtypes/movies.py +++ b/resources/lib/itemtypes/movies.py @@ -219,40 +219,40 @@ class Movie(ItemBase): kodi_pathid=kodi_pathid, last_sync=self.last_sync) - def remove(self, plex_id, plex_type=None): - """ - Remove a movie with all references and all orphaned associated entries - from the Kodi DB - """ - movie = self.plexdb.movie(plex_id) - try: - kodi_id = movie[3] - file_id = movie[4] - kodi_type = v.KODI_TYPE_MOVIE - LOG.debug('Removing movie with plex_id %s, kodi_id: %s', - plex_id, kodi_id) - except TypeError: - LOG.error('Movie with plex_id %s not found - cannot delete', - plex_id) - return - # Remove the plex reference - self.plexdb.remove(plex_id, v.PLEX_TYPE_MOVIE) - # Remove artwork - self.kodidb.delete_artwork(kodi_id, kodi_type) - set_id = self.kodidb.get_set_id(kodi_id) - self.kodidb.modify_countries(kodi_id, kodi_type) - self.kodidb.modify_people(kodi_id, kodi_type) - self.kodidb.modify_genres(kodi_id, kodi_type) - self.kodidb.modify_studios(kodi_id, kodi_type) - self.kodidb.modify_tags(kodi_id, kodi_type) - # Delete kodi movie and file - self.kodidb.remove_file(file_id) - self.kodidb.remove_movie(kodi_id) - if set_id: - self.kodidb.delete_possibly_empty_set(set_id) - self.kodidb.remove_uniqueid(kodi_id, kodi_type) - self.kodidb.remove_ratings(kodi_id, kodi_type) - LOG.debug('Deleted movie %s from kodi database', plex_id) + def remove(self, plex_id, plex_type=None): + """ + Remove a movie with all references and all orphaned associated entries + from the Kodi DB + """ + movie = self.plexdb.movie(plex_id) + try: + kodi_id = movie['kodi_id'] + file_id = movie['kodi_fileid'] + kodi_type = v.KODI_TYPE_MOVIE + LOG.debug('Removing movie with plex_id %s, kodi_id: %s', + plex_id, kodi_id) + except TypeError: + LOG.error('Movie with plex_id %s not found - cannot delete', + plex_id) + return + # Remove the plex reference + self.plexdb.remove(plex_id, v.PLEX_TYPE_MOVIE) + # Remove artwork + self.kodidb.delete_artwork(kodi_id, kodi_type) + set_id = self.kodidb.get_set_id(kodi_id) + self.kodidb.modify_countries(kodi_id, kodi_type) + self.kodidb.modify_people(kodi_id, kodi_type) + self.kodidb.modify_genres(kodi_id, kodi_type) + self.kodidb.modify_studios(kodi_id, kodi_type) + self.kodidb.modify_tags(kodi_id, kodi_type) + # Delete kodi movie and file + self.kodidb.remove_file(file_id) + self.kodidb.remove_movie(kodi_id) + if set_id: + self.kodidb.delete_possibly_empty_set(set_id) + self.kodidb.remove_uniqueid(kodi_id, kodi_type) + self.kodidb.remove_ratings(kodi_id, kodi_type) + LOG.debug('Deleted movie %s from kodi database', plex_id) def update_userdata(self, xml_element, plex_type): """