manually merged changes

This commit is contained in:
Marcel van der Veldt 2015-03-19 09:47:05 +01:00
commit 43b8cd781d
2 changed files with 76 additions and 26 deletions

View File

@ -129,8 +129,6 @@ class LibrarySync():
pDialog.update(percentage, message = "Adding Movie: " + str(count))
count += 1
#initiate library update and wait for finish before processing any updates
if updateNeeded:
if(pDialog != None):
@ -165,9 +163,6 @@ class LibrarySync():
if(self.ShouldStop()):
return True
if(self.ShouldStop()):
return True
# update progress bar
if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100))
@ -202,9 +197,6 @@ class LibrarySync():
if cleanNeeded:
self.doKodiLibraryUpdate(True)
if(self.ShouldStop()):
return True
finally:
if(pDialog != None):
pDialog.close()
@ -364,9 +356,17 @@ class LibrarySync():
#initiate library update and wait for finish before processing any updates
if updateNeeded:
if(pDialog != None):
pDialog.close()
self.doKodiLibraryUpdate()
updateNeeded = False
if(pDialog != None):
pDialog.create('Sync DB', 'Sync DB')
#process episodes (will only be possible when tv show is scanned to library)
#TODO --> maybe pull full info only when needed ?
allEpisodes = list()
@ -374,6 +374,7 @@ class LibrarySync():
showTotal = len(allTVShows)
showCurrent = 1
# do episode adds
for tvshow in allTVShows:
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
@ -392,24 +393,21 @@ class LibrarySync():
xbmc.sleep(sleepVal)
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
matchFound = False
progMessage = "Processing"
if kodiEpisodes != None:
for KodiItem in kodiEpisodes:
allEpisodes.append(KodiItem["episodeid"])
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
if comparestring1 == comparestring2:
#match found - update episode
WriteKodiDB().updateEpisodeToKodiLibrary(item,KodiItem)
matchFound = True
progMessage = "Updating"
break
if not matchFound:
#no match so we have to create it
print "episode not found...creating it: "
WriteKodiDB().addEpisodeToKodiLibrary(item)
updateNeeded = True
progMessage = "Adding"
if(self.ShouldStop()):
return True
@ -417,14 +415,61 @@ class LibrarySync():
# update progress bar
if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100))
pDialog.update(percentage, message=progMessage + " Episode: " + str(count))
pDialog.update(percentage, message="Adding Episode: " + str(count))
count += 1
showCurrent += 1
#initiate library update and wait for finish before processing any updates
if updateNeeded:
if(pDialog != None):
pDialog.close()
self.doKodiLibraryUpdate()
updateNeeded = False
if(pDialog != None):
pDialog.create('Sync DB', 'Sync DB')
# do episode updates
showCurrent = 1
for tvshow in allTVShows:
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
kodiEpisodes = ReadKodiDB().getKodiEpisodes(tvshow)
if(self.ShouldStop()):
return True
if(pDialog != None):
pDialog.update(0, "Sync DB : Processing Tv Show " + str(showCurrent) + " of " + str(showTotal))
total = len(episodeData) + 1
count = 0
#we have to compare the lists somehow
for item in episodeData:
xbmc.sleep(sleepVal)
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
matchFound = False
if kodiEpisodes != None:
for KodiItem in kodiEpisodes:
allEpisodes.append(KodiItem["episodeid"])
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
if comparestring1 == comparestring2:
#match found - update episode
WriteKodiDB().updateEpisodeToKodiLibrary(item,KodiItem,tvshow)
break
if(self.ShouldStop()):
return True
# update progress bar
if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100))
pDialog.update(percentage, message="Updating Episode: " + str(count))
count += 1
showCurrent += 1
if(pDialog != None):
pDialog.update(0, message="Removing Deleted Items")
@ -451,9 +496,6 @@ class LibrarySync():
if cleanNeeded:
self.doKodiLibraryUpdate(True)
if(self.ShouldStop()):
return True
finally:
if(pDialog != None):
pDialog.close()
@ -495,6 +537,8 @@ class LibrarySync():
#process movies
if processMovies:
views = ReadEmbyDB().getCollections("movies")
viewCount = len(views)
viewCurrent = 1
for view in views:
allMB3Movies = ReadEmbyDB().getMovies(view.get('id'),False)
@ -505,7 +549,7 @@ class LibrarySync():
return False
if(pDialog != None):
pDialog.update(0, "Sync PlayCounts: Processing Movies")
pDialog.update(0, "Sync PlayCounts: Processing " + view.get('title') + " " + str(viewCurrent) + " of " + str(viewCount))
totalCount = len(allMB3Movies) + 1
count = 1
@ -534,6 +578,8 @@ class LibrarySync():
pDialog.update(percentage, message="Updating Movie: " + str(count))
count += 1
viewCurrent += 1
#process Tv shows
if processTvShows:
tvshowData = ReadEmbyDB().getTVShows(False)
@ -544,13 +590,16 @@ class LibrarySync():
if (tvshowData == None):
return False
showTotal = len(tvshowData)
showCurrent = 1
for item in tvshowData:
xbmc.sleep(sleepVal)
episodeData = ReadEmbyDB().getEpisodes(item["Id"], False)
if (episodeData != None):
if(pDialog != None):
pDialog.update(0, "Sync PlayCounts: Processing Episodes")
pDialog.update(0, "Sync PlayCounts: Processing TV Show " + str(showCurrent) + " of " + str(showTotal))
totalCount = len(episodeData) + 1
count = 1
@ -577,6 +626,7 @@ class LibrarySync():
pDialog.update(percentage, message="Updating Episode: " + str(count))
count += 1
showCurrent += 1
finally:
if(pDialog != None):
pDialog.close()

View File

@ -10,7 +10,7 @@
<category label="Automatic sync"> <!-- Auto sync optionss -->
<setting id="enablePlayCountSync" type="bool" label="Enable watched/resume status sync" default="true" visible="true" enable="true" />
<setting id="syncSettingStartup" type="labelenum" label="Run at startup:" values="Full Sync|Incremental Sync|None" default="Full Sync" />
<setting id="syncSettingBackground" type="labelenum" label="Enable continuous background sync:" values="Full Sync|Incremental Sync|None" default="Incremental Sync" visible="true" enable="true" />
<setting id="syncSettingBackground" type="labelenum" label="Enable continuous background sync:" values="Full Sync|Incremental Sync|None" default="Full Sync" visible="true" enable="true" />
<setting type="lsep"/>
<setting label="[B]Full Sync:[/B] Performs full compare including deletes" type="lsep"/>
<setting label="[B]Incremental Sync:[/B] Processes only new items" type="lsep"/>