nonetype fixes and prevent doubled episodes

This commit is contained in:
Marcel van der Veldt 2015-03-29 23:09:02 +02:00
parent c680a7d0fe
commit 7481023bd8

View file

@ -168,7 +168,11 @@ class LibrarySync():
item['Tag'] = [] item['Tag'] = []
item['Tag'].append(view.get('title')) 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): if(kodimovie != None):
#WriteKodiDB().updateMovieToKodiLibrary(item, kodimovie) #WriteKodiDB().updateMovieToKodiLibrary(item, kodimovie)
updated = WriteKodiDB().updateMovieToKodiLibrary_Batched(item, kodimovie) updated = WriteKodiDB().updateMovieToKodiLibrary_Batched(item, kodimovie)
@ -333,6 +337,7 @@ class LibrarySync():
progressAction = "Checking" progressAction = "Checking"
if not matchFound: if not matchFound:
#no match so we have to create it #no match so we have to create it
print "creating episode in incremental sync!"
WriteKodiDB().addEpisodeToKodiLibrary(episode) WriteKodiDB().addEpisodeToKodiLibrary(episode)
updateNeeded = True updateNeeded = True
progressAction = "Adding" progressAction = "Adding"
@ -467,11 +472,13 @@ class LibrarySync():
progressAction = "Checking" progressAction = "Checking"
if not matchFound: if not matchFound:
#no match so we have to create it #double check the item it might me added delayed by the Kodi scanner
WriteKodiDB().addEpisodeToKodiLibrary(item) if ReadKodiDB().getKodiEpisodeByMbItem(item["Id"],tvshow) == None:
updateNeeded = True #no match so we have to create it
progressAction = "Adding" WriteKodiDB().addEpisodeToKodiLibrary(item)
totalItemsAdded += 1 updateNeeded = True
progressAction = "Adding"
totalItemsAdded += 1
if(self.ShouldStop(pDialog)): if(self.ShouldStop(pDialog)):
return False return False
@ -728,7 +735,11 @@ class LibrarySync():
if not item.get('IsFolder'): 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): if(kodimusicvideo != None):
#WriteKodiDB().updateMusicVideoToKodiLibrary(item, kodimusicvideo) #WriteKodiDB().updateMusicVideoToKodiLibrary(item, kodimusicvideo)
WriteKodiDB().updateMusicVideoToKodiLibrary_Batched(item, kodimusicvideo) WriteKodiDB().updateMusicVideoToKodiLibrary_Batched(item, kodimusicvideo)
@ -894,7 +905,10 @@ class LibrarySync():
episodeData = ReadEmbyDB().getEpisodes(item["Id"], False) episodeData = ReadEmbyDB().getEpisodes(item["Id"], False)
allKodiTVShows = ReadKodiDB().getKodiTvShows(False) allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
kodishow = allKodiTVShows.get(item["Id"],None) 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 (episodeData != None):
if(pDialog != None): if(pDialog != None):