mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 18:26:15 +00:00
add xbmcgui.DialogProgressBG() to display current sync progress
This commit is contained in:
parent
f0fb4e3c96
commit
f587905d91
2 changed files with 218 additions and 131 deletions
|
@ -35,6 +35,14 @@ class LibrarySync():
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
WINDOW.setProperty("librarysync", "busy")
|
WINDOW.setProperty("librarysync", "busy")
|
||||||
|
pDialog = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
pDialog = xbmcgui.DialogProgressBG()
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.create('Sync DB', 'Sync DB')
|
||||||
|
|
||||||
updateNeeded = False
|
updateNeeded = False
|
||||||
|
|
||||||
#process full movies sync
|
#process full movies sync
|
||||||
|
@ -44,15 +52,29 @@ class LibrarySync():
|
||||||
if(movieData == None):
|
if(movieData == None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, "Sync DB : Processing Movies")
|
||||||
|
total = len(movieData) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
for item in movieData:
|
for item in movieData:
|
||||||
if not item.get('IsFolder'):
|
if not item.get('IsFolder'):
|
||||||
kodiItem = self.getKodiMovie(item["Id"])
|
kodiItem = self.getKodiMovie(item["Id"])
|
||||||
allMovies.append(item["Id"])
|
allMovies.append(item["Id"])
|
||||||
|
progMessage = "Processing"
|
||||||
if kodiItem == None:
|
if kodiItem == None:
|
||||||
self.addMovieToKodiLibrary(item)
|
self.addMovieToKodiLibrary(item)
|
||||||
updateNeeded = True
|
updateNeeded = True
|
||||||
|
progMessage = "Adding"
|
||||||
else:
|
else:
|
||||||
self.updateMovieToKodiLibrary(item, kodiItem)
|
self.updateMovieToKodiLibrary(item, kodiItem)
|
||||||
|
progMessage = "Updating"
|
||||||
|
|
||||||
|
# update progress bar
|
||||||
|
if(pDialog != None):
|
||||||
|
percentage = int(((float(count) / float(total)) * 100))
|
||||||
|
pDialog.update(percentage, message=progMessage + " Movie: " + str(count))
|
||||||
|
count += 1
|
||||||
|
|
||||||
#process full tv shows sync
|
#process full tv shows sync
|
||||||
allTVShows = list()
|
allTVShows = list()
|
||||||
|
@ -61,15 +83,30 @@ class LibrarySync():
|
||||||
|
|
||||||
if (tvShowData == None):
|
if (tvShowData == None):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, "Sync DB : Processing TV Shows")
|
||||||
|
total = len(tvShowData) + 1
|
||||||
|
count = 0
|
||||||
|
|
||||||
for item in tvShowData:
|
for item in tvShowData:
|
||||||
if item.get('IsFolder'):
|
if item.get('IsFolder'):
|
||||||
kodiItem = self.getKodiTVShow(item["Id"])
|
kodiItem = self.getKodiTVShow(item["Id"])
|
||||||
allTVShows.append(item["Id"])
|
allTVShows.append(item["Id"])
|
||||||
|
progMessage = "Processing"
|
||||||
if kodiItem == None:
|
if kodiItem == None:
|
||||||
self.addTVShowToKodiLibrary(item)
|
self.addTVShowToKodiLibrary(item)
|
||||||
updateNeeded = True
|
updateNeeded = True
|
||||||
|
progMessage = "Adding"
|
||||||
else:
|
else:
|
||||||
self.updateTVShowToKodiLibrary(item, kodiItem)
|
self.updateTVShowToKodiLibrary(item, kodiItem)
|
||||||
|
progMessage = "Updating"
|
||||||
|
|
||||||
|
# update progress bar
|
||||||
|
if(pDialog != None):
|
||||||
|
percentage = int(((float(count) / float(total)) * 100))
|
||||||
|
pDialog.update(percentage, message=progMessage + " Tv Show: " + str(count))
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
#process episodes (will only be possible when tv show is scanned to library)
|
#process episodes (will only be possible when tv show is scanned to library)
|
||||||
|
@ -81,11 +118,17 @@ class LibrarySync():
|
||||||
episodeData = self.getEpisodes(tvshow,True)
|
episodeData = self.getEpisodes(tvshow,True)
|
||||||
kodiEpisodes = self.getKodiEpisodes(tvshow)
|
kodiEpisodes = self.getKodiEpisodes(tvshow)
|
||||||
|
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, "Sync DB : Processing Episodes")
|
||||||
|
total = len(episodeData) + 1
|
||||||
|
count = 0
|
||||||
|
|
||||||
#we have to compare the lists somehow
|
#we have to compare the lists somehow
|
||||||
for item in episodeData:
|
for item in episodeData:
|
||||||
xbmc.sleep(150) # sleep to not overload system --> can this be replaced by moving the sync to a different thread ?
|
#xbmc.sleep(150) # sleep to not overload system --> can this be replaced by moving the sync to a different thread ?
|
||||||
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
||||||
matchFound = False
|
matchFound = False
|
||||||
|
progMessage = "Processing"
|
||||||
if kodiEpisodes != None:
|
if kodiEpisodes != None:
|
||||||
for KodiItem in kodiEpisodes:
|
for KodiItem in kodiEpisodes:
|
||||||
|
|
||||||
|
@ -95,16 +138,26 @@ class LibrarySync():
|
||||||
#match found - update episode
|
#match found - update episode
|
||||||
self.updateEpisodeToKodiLibrary(item,KodiItem,tvshow)
|
self.updateEpisodeToKodiLibrary(item,KodiItem,tvshow)
|
||||||
matchFound = True
|
matchFound = True
|
||||||
|
progMessage = "Updating"
|
||||||
|
|
||||||
if not matchFound:
|
if not matchFound:
|
||||||
#no match so we have to create it
|
#no match so we have to create it
|
||||||
print "episode not found...creating it: "
|
print "episode not found...creating it: "
|
||||||
self.addEpisodeToKodiLibrary(item,tvshow)
|
self.addEpisodeToKodiLibrary(item,tvshow)
|
||||||
updateNeeded = True
|
updateNeeded = True
|
||||||
|
progMessage = "Adding"
|
||||||
|
|
||||||
|
# update progress bar
|
||||||
|
if(pDialog != None):
|
||||||
|
percentage = int(((float(count) / float(total)) * 100))
|
||||||
|
pDialog.update(percentage, message=progMessage + " Episode: " + str(count))
|
||||||
|
count += 1
|
||||||
|
|
||||||
# process deletes
|
# process deletes
|
||||||
# TODO --> process deletes for episodes !!!
|
# TODO --> process deletes for episodes !!!
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, message="Removing Deleted Items")
|
||||||
|
|
||||||
cleanNeeded = False
|
cleanNeeded = False
|
||||||
allLocaldirs, filesMovies = xbmcvfs.listdir(movieLibrary)
|
allLocaldirs, filesMovies = xbmcvfs.listdir(movieLibrary)
|
||||||
allMB3Movies = set(allMovies)
|
allMB3Movies = set(allMovies)
|
||||||
|
@ -126,7 +179,10 @@ class LibrarySync():
|
||||||
if updateNeeded:
|
if updateNeeded:
|
||||||
xbmc.executebuiltin("UpdateLibrary(video)")
|
xbmc.executebuiltin("UpdateLibrary(video)")
|
||||||
|
|
||||||
|
finally:
|
||||||
WINDOW.clearProperty("librarysync")
|
WINDOW.clearProperty("librarysync")
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.close()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -135,12 +191,24 @@ class LibrarySync():
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
WINDOW.setProperty("librarysync", "busy")
|
WINDOW.setProperty("librarysync", "busy")
|
||||||
|
pDialog = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
pDialog = xbmcgui.DialogProgressBG()
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.create('Sync PlayCounts', 'Sync PlayCounts')
|
||||||
|
|
||||||
#process movies
|
#process movies
|
||||||
movieData = self.getMovies(False)
|
movieData = self.getMovies(False)
|
||||||
if(movieData == None):
|
if(movieData == None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, "Sync PlayCounts: Processing Movies")
|
||||||
|
totalCount = len(movieData) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
for item in movieData:
|
for item in movieData:
|
||||||
if not item.get('IsFolder'):
|
if not item.get('IsFolder'):
|
||||||
kodiItem = self.getKodiMovie(item["Id"])
|
kodiItem = self.getKodiMovie(item["Id"])
|
||||||
|
@ -156,17 +224,26 @@ class LibrarySync():
|
||||||
if kodiresume != resume:
|
if kodiresume != resume:
|
||||||
self.setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
self.setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
||||||
|
|
||||||
|
# update progress bar
|
||||||
|
if(pDialog != None):
|
||||||
|
percentage = int(((float(count) / float(totalCount)) * 100))
|
||||||
|
pDialog.update(percentage, message="Updating Movie: " + str(count))
|
||||||
|
count += 1
|
||||||
|
|
||||||
#process Tv shows
|
#process Tv shows
|
||||||
tvshowData = self.getTVShows(False)
|
tvshowData = self.getTVShows(False)
|
||||||
if (tvshowData == None):
|
if (tvshowData == None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, "Sync PlayCounts: Processing Episodes")
|
||||||
|
totalCount = len(movieData) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
for item in tvshowData:
|
for item in tvshowData:
|
||||||
episodeData = self.getEpisodes(item["Id"], False)
|
episodeData = self.getEpisodes(item["Id"], False)
|
||||||
|
|
||||||
if (episodeData == None):
|
if (episodeData != None):
|
||||||
return False
|
|
||||||
|
|
||||||
for episode in episodeData:
|
for episode in episodeData:
|
||||||
kodiItem = self.getKodiEpisodeByMbItem(episode)
|
kodiItem = self.getKodiEpisodeByMbItem(episode)
|
||||||
userData=API().getUserData(episode)
|
userData=API().getUserData(episode)
|
||||||
|
@ -181,8 +258,16 @@ class LibrarySync():
|
||||||
if kodiresume != resume:
|
if kodiresume != resume:
|
||||||
self.setKodiResumePoint(kodiItem['episodeid'],resume,total,"episode")
|
self.setKodiResumePoint(kodiItem['episodeid'],resume,total,"episode")
|
||||||
|
|
||||||
|
# update progress bar
|
||||||
|
if(pDialog != None):
|
||||||
|
percentage = int(((float(count) / float(totalCount)) * 100))
|
||||||
|
pDialog.update(percentage, message="Updating Episode: " + str(count))
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
finally:
|
||||||
WINDOW.clearProperty("librarysync")
|
WINDOW.clearProperty("librarysync")
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.close()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,9 @@ class Service():
|
||||||
|
|
||||||
#full sync
|
#full sync
|
||||||
if(cur_seconds_fullsync >= interval_FullSync):
|
if(cur_seconds_fullsync >= interval_FullSync):
|
||||||
xbmc.log("Doing_Db_Sync: syncDatabase")
|
xbmc.log("Doing_Db_Sync: syncDatabase (Started)")
|
||||||
worked = librarySync.syncDatabase()
|
worked = librarySync.syncDatabase()
|
||||||
|
xbmc.log("Doing_Db_Sync: syncDatabase (Finished) " + str(worked))
|
||||||
if(worked):
|
if(worked):
|
||||||
cur_seconds_fullsync = 0
|
cur_seconds_fullsync = 0
|
||||||
else:
|
else:
|
||||||
|
@ -95,8 +96,9 @@ class Service():
|
||||||
|
|
||||||
#incremental sync
|
#incremental sync
|
||||||
if(cur_seconds_incrsync >= interval_IncrementalSync):
|
if(cur_seconds_incrsync >= interval_IncrementalSync):
|
||||||
xbmc.log("Doing_Db_Sync: updatePlayCounts")
|
xbmc.log("Doing_Db_Sync: updatePlayCounts (Started)")
|
||||||
worked = librarySync.updatePlayCounts()
|
worked = librarySync.updatePlayCounts()
|
||||||
|
xbmc.log("Doing_Db_Sync: updatePlayCounts (Finished) " + str(worked))
|
||||||
if(worked):
|
if(worked):
|
||||||
cur_seconds_incrsync = 0
|
cur_seconds_incrsync = 0
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue