use uniqueid to check of en episode is already in the DB

This commit is contained in:
shaun 2015-04-05 09:32:42 +10:00
commit 85482119a0
3 changed files with 19 additions and 43 deletions

View file

@ -435,17 +435,7 @@ class LibrarySync():
# do episode adds
for tvshow in viewTVShows:
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
if allKodiTVShows != None:
kodishow = allKodiTVShows.get(tvshow,None)
if kodishow != None:
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],True,True)
else:
kodiEpisodes = None
else:
kodiEpisodes = None
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
if episodeData != None:
if(self.ShouldStop(pDialog)):
@ -457,32 +447,11 @@ class LibrarySync():
total = len(episodeData) + 1
count = 0
#we have to compare the lists somehow
# TODO --> instead of matching by season and episode number we can use the uniqueid
for item in episodeData:
if(installFirstRun):
progressAction = "Adding"
WriteKodiDB().addEpisodeToKodiLibrary(item, connection, cursor)
else:
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
matchFound = False
if kodiEpisodes != None:
KodiItem = kodiEpisodes.get(comparestring1, None)
if(KodiItem != None):
matchFound = True
progressAction = "Checking"
if not matchFound:
#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,connection, cursor)
progressAction = "Adding"
totalItemsAdded += 1
if(self.ShouldStop(pDialog)):
return False
#if(installFirstRun):
progressAction = "Adding"
WriteKodiDB().addEpisodeToKodiLibrary(item, connection, cursor)
# update progress bar
if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100))