From 21fb1ad01574c2cab35dfc96f128494867b23d95 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 23 Sep 2018 13:52:08 +0200 Subject: [PATCH] Ensure shows are deleted before seasons before episodes --- resources/lib/librarysync.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index e13b2b08..8209b0ca 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -6,6 +6,7 @@ from threading import Thread import Queue from random import shuffle import copy +from collections import OrderedDict import xbmc from xbmcvfs import exists @@ -65,7 +66,7 @@ class LibrarySync(Thread): self.old_views = [] self.updatelist = [] self.all_plex_ids = {} - self.all_kodi_ids = {} + self.all_kodi_ids = OrderedDict() Thread.__init__(self) def suspend_item_sync(self): @@ -726,16 +727,16 @@ class LibrarySync(Thread): views = [x for x in self.views if x['itemtype'] == v.KODI_TYPE_MOVIE] LOG.info("Processing Plex %s. Libraries: %s", item_class, views) - self.all_kodi_ids = {} + self.all_kodi_ids = OrderedDict() if self.compare: with plexdb.Get_Plex_DB() as plex_db: # Get movies from Plex server # Pull the list of movies and boxsets in Kodi try: - self.all_kodi_ids = dict( + self.all_kodi_ids = OrderedDict( plex_db.checksum(v.PLEX_TYPE_MOVIE)) except ValueError: - self.all_kodi_ids = {} + self.all_kodi_ids = OrderedDict() # PROCESS MOVIES ##### self.updatelist = [] @@ -813,7 +814,7 @@ class LibrarySync(Thread): views = [x for x in self.views if x['itemtype'] == 'show'] LOG.info("Media folders for %s: %s", item_class, views) - self.all_kodi_ids = {} + self.all_kodi_ids = OrderedDict() if self.compare: with plexdb.Get_Plex_DB() as plex: # Pull the list of TV shows already in Kodi @@ -961,7 +962,7 @@ class LibrarySync(Thread): if self.suspend_item_sync(): return False LOG.debug("Start processing music %s", kind) - self.all_kodi_ids = {} + self.all_kodi_ids = OrderedDict() self.all_plex_ids = {} self.updatelist = [] if not self.process_music(views, @@ -980,7 +981,7 @@ class LibrarySync(Thread): self.plex_update_watched(view['id'], item_class) # reset stuff - self.all_kodi_ids = {} + self.all_kodi_ids = OrderedDict() self.all_plex_ids = {} self.updatelist = [] LOG.info("%s sync is finished.", item_class)