mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
split the tv episide add into two stages add/update to allow importing in the middle
This commit is contained in:
parent
c2f25724a3
commit
00e46a76cb
2 changed files with 76 additions and 28 deletions
|
@ -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()
|
||||
|
@ -366,9 +358,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()
|
||||
|
@ -376,6 +376,7 @@ class LibrarySync():
|
|||
showTotal = len(allTVShows)
|
||||
showCurrent = 1
|
||||
|
||||
# do episode adds
|
||||
for tvshow in allTVShows:
|
||||
|
||||
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
||||
|
@ -394,24 +395,19 @@ 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,tvshow)
|
||||
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,tvshow)
|
||||
updateNeeded = True
|
||||
progMessage = "Adding"
|
||||
|
||||
if(self.ShouldStop()):
|
||||
return True
|
||||
|
@ -419,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")
|
||||
|
@ -453,9 +496,6 @@ class LibrarySync():
|
|||
if cleanNeeded:
|
||||
self.doKodiLibraryUpdate(True)
|
||||
|
||||
if(self.ShouldStop()):
|
||||
return True
|
||||
|
||||
finally:
|
||||
if(pDialog != None):
|
||||
pDialog.close()
|
||||
|
@ -497,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)
|
||||
|
||||
|
@ -507,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
|
||||
|
||||
|
@ -536,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)
|
||||
|
@ -546,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
|
||||
|
||||
|
@ -579,6 +626,7 @@ class LibrarySync():
|
|||
pDialog.update(percentage, message="Updating Episode: " + str(count))
|
||||
count += 1
|
||||
|
||||
showCurrent += 1
|
||||
finally:
|
||||
if(pDialog != None):
|
||||
pDialog.close()
|
||||
|
|
|
@ -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"/>
|
||||
|
|
Loading…
Reference in a new issue