small changes

This commit is contained in:
Marcel van der Veldt 2015-03-18 22:38:02 +01:00
parent 62b3f8da2d
commit 53fb4a9207
1 changed files with 85 additions and 82 deletions

View File

@ -218,93 +218,96 @@ class LibrarySync():
# incremental sync --> new episodes only
if not fullsync:
latestMBEpisodes = ReadEmbyDB().getLatestEpisodes(True)
allKodiTvShowsIds = set(ReadKodiDB().getKodiTvShowsIds(True))
updateNeeded = False
# 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()
if latestMBEpisodes != None:
allKodiTvShowsIds = set(ReadKodiDB().getKodiTvShowsIds(True))
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"
# 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(self.ShouldStop()):
return True
if(pDialog != None):
pDialog.update(0, "Sync DB : Processing Episodes")
total = len(latestMBEpisodes) + 1
count = 0
# update progress bar
if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100))
pDialog.update(percentage, message=progMessage + " Episode: " + str(count))
count += 1
#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
#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
if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100))
pDialog.update(percentage, message=progMessage + " Episode: " + str(count))
count += 1
# full sync --> Tv shows and Episodes
if fullsync: