small changes

This commit is contained in:
Marcel van der Veldt 2015-03-18 22:38:02 +01:00
parent 62b3f8da2d
commit 53fb4a9207

View file

@ -218,92 +218,95 @@ class LibrarySync():
# incremental sync --> new episodes only # incremental sync --> new episodes only
if not fullsync: if not fullsync:
latestMBEpisodes = ReadEmbyDB().getLatestEpisodes(True) latestMBEpisodes = ReadEmbyDB().getLatestEpisodes(True)
allKodiTvShowsIds = set(ReadKodiDB().getKodiTvShowsIds(True))
updateNeeded = False if latestMBEpisodes != None:
allKodiTvShowsIds = set(ReadKodiDB().getKodiTvShowsIds(True))
# process new episodes
for tvshow in latestMBEpisodes:
if tvshow["SeriesId"] in allKodiTvShowsIds:
#only process tvshows that already exist in the db at incremental updates
kodiEpisodes = ReadKodiDB().getKodiEpisodes(tvshow["SeriesId"])
if(self.ShouldStop()):
return True
if(pDialog != None):
pDialog.update(0, "Sync DB : Processing Episodes")
total = len(latestMBEpisodes) + 1
count = 0
#we have to compare the lists somehow
xbmc.sleep(sleepVal)
comparestring1 = str(tvshow.get("ParentIndexNumber")) + "-" + str(tvshow.get("IndexNumber"))
matchFound = False
progMessage = "Processing"
if kodiEpisodes != None:
for KodiItem in kodiEpisodes:
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
if comparestring1 == comparestring2:
matchFound = True
if not matchFound:
#no match so we have to create it
WriteKodiDB().addEpisodeToKodiLibrary(tvshow,tvshow)
updateNeeded = True
progMessage = "Adding"
if(self.ShouldStop()):
return True
# update progress bar
if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100))
pDialog.update(percentage, message=progMessage + " Episode: " + str(count))
count += 1
#initiate library update and wait for finish before processing any updates
if updateNeeded:
self.doKodiLibraryUpdate()
updateNeeded = False updateNeeded = False
#process updates # process new episodes
for tvshow in latestMBEpisodes: for tvshow in latestMBEpisodes:
if tvshow["SeriesId"] in allKodiTvShowsIds: if tvshow["SeriesId"] in allKodiTvShowsIds:
#only process tvshows that already exist in the db at incremental updates #only process tvshows that already exist in the db at incremental updates
kodiEpisodes = ReadKodiDB().getKodiEpisodes(tvshow["SeriesId"]) kodiEpisodes = ReadKodiDB().getKodiEpisodes(tvshow["SeriesId"])
if(self.ShouldStop()): if(self.ShouldStop()):
return True return True
if(pDialog != None): if(pDialog != None):
pDialog.update(0, "Sync DB : Processing Episodes") pDialog.update(0, "Sync DB : Processing Episodes")
total = len(latestMBEpisodes) + 1 total = len(latestMBEpisodes) + 1
count = 0 count = 0
#we have to compare the lists somehow #we have to compare the lists somehow
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)
comparestring1 = str(tvshow.get("ParentIndexNumber")) + "-" + str(tvshow.get("IndexNumber")) comparestring1 = str(tvshow.get("ParentIndexNumber")) + "-" + str(tvshow.get("IndexNumber"))
progMessage = "Processing" matchFound = False
if kodiEpisodes != None: progMessage = "Processing"
for KodiItem in kodiEpisodes: if kodiEpisodes != None:
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"]) for KodiItem in kodiEpisodes:
if comparestring1 == comparestring2:
#match found - update episode
progMessage = "Updating" comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
if comparestring1 == comparestring2:
matchFound = True
if(self.ShouldStop()): if not matchFound:
return True #no match so we have to create it
WriteKodiDB().addEpisodeToKodiLibrary(tvshow,tvshow)
updateNeeded = True
progMessage = "Adding"
if(self.ShouldStop()):
return True
# update progress bar
if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100))
pDialog.update(percentage, message=progMessage + " Episode: " + str(count))
count += 1
#initiate library update and wait for finish before processing any updates
if updateNeeded:
self.doKodiLibraryUpdate()
updateNeeded = False
#process updates
for tvshow in latestMBEpisodes:
if tvshow["SeriesId"] in allKodiTvShowsIds:
#only process tvshows that already exist in the db at incremental updates
kodiEpisodes = ReadKodiDB().getKodiEpisodes(tvshow["SeriesId"])
if(self.ShouldStop()):
return True
if(pDialog != None):
pDialog.update(0, "Sync DB : Processing Episodes")
total = len(latestMBEpisodes) + 1
count = 0
#we have to compare the lists somehow
xbmc.sleep(sleepVal)
comparestring1 = str(tvshow.get("ParentIndexNumber")) + "-" + str(tvshow.get("IndexNumber"))
progMessage = "Processing"
if kodiEpisodes != None:
for KodiItem in kodiEpisodes:
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
if comparestring1 == comparestring2:
#match found - update episode
progMessage = "Updating"
if(self.ShouldStop()):
return True
# update progress bar # update progress bar
if(pDialog != None): if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100)) percentage = int(((float(count) / float(total)) * 100))
pDialog.update(percentage, message=progMessage + " Episode: " + str(count)) pDialog.update(percentage, message=progMessage + " Episode: " + str(count))
count += 1 count += 1
# full sync --> Tv shows and Episodes # full sync --> Tv shows and Episodes