From 7481023bd80573c80fabd8e3cf3d5c473ac0a134 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sun, 29 Mar 2015 23:09:02 +0200 Subject: [PATCH] nonetype fixes and prevent doubled episodes --- resources/lib/LibrarySync.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index f7defa6d..1cc46d7e 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -168,7 +168,11 @@ class LibrarySync(): item['Tag'] = [] item['Tag'].append(view.get('title')) - kodimovie = allKodiMovies.get(item["Id"], None) + if allKodiMovies != None: + kodimovie = allKodiMovies.get(item["Id"], None) + else: + kodimovie = None + if(kodimovie != None): #WriteKodiDB().updateMovieToKodiLibrary(item, kodimovie) updated = WriteKodiDB().updateMovieToKodiLibrary_Batched(item, kodimovie) @@ -333,6 +337,7 @@ class LibrarySync(): progressAction = "Checking" if not matchFound: #no match so we have to create it + print "creating episode in incremental sync!" WriteKodiDB().addEpisodeToKodiLibrary(episode) updateNeeded = True progressAction = "Adding" @@ -467,11 +472,13 @@ class LibrarySync(): progressAction = "Checking" if not matchFound: - #no match so we have to create it - WriteKodiDB().addEpisodeToKodiLibrary(item) - updateNeeded = True - progressAction = "Adding" - totalItemsAdded += 1 + #double check the item it might me added delayed by the Kodi scanner + if ReadKodiDB().getKodiEpisodeByMbItem(item["Id"],tvshow) == None: + #no match so we have to create it + WriteKodiDB().addEpisodeToKodiLibrary(item) + updateNeeded = True + progressAction = "Adding" + totalItemsAdded += 1 if(self.ShouldStop(pDialog)): return False @@ -727,8 +734,12 @@ class LibrarySync(): for item in allMB3MusicVideos: if not item.get('IsFolder'): - - kodimusicvideo = allKodiMusicVideos.get(item["Id"], None) + + if allKodiMusicVideos != None: + kodimusicvideo = allKodiMusicVideos.get(item["Id"], None) + else: + kodimusicvideo = None + if(kodimusicvideo != None): #WriteKodiDB().updateMusicVideoToKodiLibrary(item, kodimusicvideo) WriteKodiDB().updateMusicVideoToKodiLibrary_Batched(item, kodimusicvideo) @@ -894,7 +905,10 @@ class LibrarySync(): episodeData = ReadEmbyDB().getEpisodes(item["Id"], False) allKodiTVShows = ReadKodiDB().getKodiTvShows(False) kodishow = allKodiTVShows.get(item["Id"],None) - kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],False,True) + if kodishow != None: + kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],False,True) + else: + kodiEpisodes = None if (episodeData != None): if(pDialog != None):