mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
a bunch of progress dialog fixes
This commit is contained in:
parent
7d37fe590d
commit
20691716b7
1 changed files with 67 additions and 51 deletions
|
@ -23,23 +23,18 @@ from ReadKodiDB import ReadKodiDB
|
||||||
from WriteKodiDB import WriteKodiDB
|
from WriteKodiDB import WriteKodiDB
|
||||||
from CreateFiles import CreateFiles
|
from CreateFiles import CreateFiles
|
||||||
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
addondir = xbmc.translatePath(xbmcaddon.Addon(id='plugin.video.mb3sync').getAddonInfo('profile'))
|
||||||
addondir = xbmc.translatePath(addon.getAddonInfo('profile'))
|
|
||||||
dataPath = os.path.join(addondir,"library")
|
dataPath = os.path.join(addondir,"library")
|
||||||
movieLibrary = os.path.join(dataPath,'movies')
|
movieLibrary = os.path.join(dataPath,'movies')
|
||||||
tvLibrary = os.path.join(dataPath,'tvshows')
|
tvLibrary = os.path.join(dataPath,'tvshows')
|
||||||
|
|
||||||
sleepVal = 20
|
sleepVal = 20
|
||||||
showProgress = True
|
|
||||||
|
|
||||||
processMovies = True
|
|
||||||
processTvShows = False
|
|
||||||
|
|
||||||
|
|
||||||
class LibrarySync():
|
class LibrarySync():
|
||||||
|
|
||||||
def syncDatabase(self):
|
def syncDatabase(self):
|
||||||
|
|
||||||
|
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
pDialog = None
|
pDialog = None
|
||||||
|
|
||||||
|
@ -69,6 +64,7 @@ class LibrarySync():
|
||||||
|
|
||||||
def MoviesSync(self, fullsync=True):
|
def MoviesSync(self, fullsync=True):
|
||||||
|
|
||||||
|
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
pDialog = None
|
pDialog = None
|
||||||
|
|
||||||
|
@ -76,6 +72,9 @@ class LibrarySync():
|
||||||
enableProgress = False
|
enableProgress = False
|
||||||
if addon.getSetting("enableProgressFullSync") == 'true':
|
if addon.getSetting("enableProgressFullSync") == 'true':
|
||||||
enableProgress = True
|
enableProgress = True
|
||||||
|
startupStr = WINDOW.getProperty("startup")
|
||||||
|
if startupStr != "done":
|
||||||
|
enableProgress = True
|
||||||
if(enableProgress):
|
if(enableProgress):
|
||||||
pDialog = xbmcgui.DialogProgressBG()
|
pDialog = xbmcgui.DialogProgressBG()
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
|
@ -84,6 +83,8 @@ class LibrarySync():
|
||||||
allEmbyMovieIds = list()
|
allEmbyMovieIds = list()
|
||||||
|
|
||||||
views = ReadEmbyDB().getCollections("movies")
|
views = ReadEmbyDB().getCollections("movies")
|
||||||
|
viewCount = len(views)
|
||||||
|
viewCurrent = 1
|
||||||
|
|
||||||
for view in views:
|
for view in views:
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ class LibrarySync():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.update(0, "Sync DB : Processing " + view.get('title'))
|
pDialog.update(0, "Sync DB : Processing " + view.get('title') + " " + str(viewCurrent) + " of " + str(viewCount))
|
||||||
total = len(allMB3Movies) + 1
|
total = len(allMB3Movies) + 1
|
||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
|
@ -108,7 +109,6 @@ class LibrarySync():
|
||||||
|
|
||||||
if not item.get('IsFolder'):
|
if not item.get('IsFolder'):
|
||||||
allEmbyMovieIds.append(item["Id"])
|
allEmbyMovieIds.append(item["Id"])
|
||||||
progMessage = "Updating movies"
|
|
||||||
item['Tag'] = []
|
item['Tag'] = []
|
||||||
item['Tag'].append(view.get('title'))
|
item['Tag'].append(view.get('title'))
|
||||||
|
|
||||||
|
@ -116,7 +116,6 @@ class LibrarySync():
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
WriteKodiDB().addMovieToKodiLibrary(item)
|
WriteKodiDB().addMovieToKodiLibrary(item)
|
||||||
updateNeeded = True
|
updateNeeded = True
|
||||||
progMessage = "Adding"
|
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
@ -127,27 +126,37 @@ class LibrarySync():
|
||||||
# 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 + " Movie: " + str(count))
|
pDialog.update(percentage, message = "Adding Movie: " + str(count))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#initiate library update and wait for finish before processing any updates
|
#initiate library update and wait for finish before processing any updates
|
||||||
if updateNeeded:
|
if updateNeeded:
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.close()
|
||||||
|
|
||||||
self.doKodiLibraryUpdate()
|
self.doKodiLibraryUpdate()
|
||||||
|
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.create('Sync DB', 'Sync DB')
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, "Sync DB : Processing " + view.get('title') + " " + str(viewCurrent) + " of " + str(viewCount))
|
||||||
|
total = len(allMB3Movies) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
#process updates
|
#process updates
|
||||||
allKodiMovies = ReadKodiDB().getKodiMovies(True)
|
allKodiMovies = ReadKodiDB().getKodiMovies(True)
|
||||||
for item in allMB3Movies:
|
for item in allMB3Movies:
|
||||||
|
|
||||||
if not item.get('IsFolder'):
|
if not item.get('IsFolder'):
|
||||||
progMessage = "Updating movies"
|
|
||||||
item['Tag'] = []
|
item['Tag'] = []
|
||||||
item['Tag'].append(view.get('title'))
|
item['Tag'].append(view.get('title'))
|
||||||
|
|
||||||
progMessage = "Updating"
|
|
||||||
|
|
||||||
for kodimovie in allKodiMovies:
|
for kodimovie in allKodiMovies:
|
||||||
if item["Id"] in kodimovie["file"]:
|
if item["Id"] in kodimovie["file"]:
|
||||||
WriteKodiDB().updateMovieToKodiLibrary(item,kodimovie)
|
WriteKodiDB().updateMovieToKodiLibrary(item,kodimovie)
|
||||||
|
@ -162,9 +171,11 @@ class LibrarySync():
|
||||||
# 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 + " Movie: " + str(count))
|
pDialog.update(percentage, message="Updating Movie: " + str(count))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
viewCurrent += 1
|
||||||
|
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.update(0, message="Removing Deleted Items")
|
pDialog.update(0, message="Removing Deleted Items")
|
||||||
|
|
||||||
|
@ -189,13 +200,11 @@ class LibrarySync():
|
||||||
|
|
||||||
#initiate library clean and wait for finish before processing any updates
|
#initiate library clean and wait for finish before processing any updates
|
||||||
if cleanNeeded:
|
if cleanNeeded:
|
||||||
doKodiLibraryUpdate(True)
|
self.doKodiLibraryUpdate(True)
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except Exception, msg:
|
|
||||||
print "Exception in MoviesSync --> " + str(msg)
|
|
||||||
finally:
|
finally:
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.close()
|
pDialog.close()
|
||||||
|
@ -204,6 +213,7 @@ class LibrarySync():
|
||||||
|
|
||||||
def TvShowsSync(self, fullsync=True):
|
def TvShowsSync(self, fullsync=True):
|
||||||
|
|
||||||
|
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
pDialog = None
|
pDialog = None
|
||||||
|
|
||||||
|
@ -211,6 +221,9 @@ class LibrarySync():
|
||||||
enableProgress = False
|
enableProgress = False
|
||||||
if addon.getSetting("enableProgressFullSync") == 'true':
|
if addon.getSetting("enableProgressFullSync") == 'true':
|
||||||
enableProgress = True
|
enableProgress = True
|
||||||
|
startupStr = WINDOW.getProperty("startup")
|
||||||
|
if startupStr != "done":
|
||||||
|
enableProgress = True
|
||||||
if(enableProgress):
|
if(enableProgress):
|
||||||
pDialog = xbmcgui.DialogProgressBG()
|
pDialog = xbmcgui.DialogProgressBG()
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
|
@ -226,6 +239,11 @@ class LibrarySync():
|
||||||
|
|
||||||
updateNeeded = False
|
updateNeeded = False
|
||||||
|
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, "Sync DB : Processing Episodes")
|
||||||
|
total = len(latestMBEpisodes) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
# process new episodes
|
# process new episodes
|
||||||
for tvshow in latestMBEpisodes:
|
for tvshow in latestMBEpisodes:
|
||||||
if tvshow["SeriesId"] in allKodiTvShowsIds:
|
if tvshow["SeriesId"] in allKodiTvShowsIds:
|
||||||
|
@ -235,28 +253,21 @@ class LibrarySync():
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
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
|
#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"))
|
||||||
matchFound = False
|
matchFound = False
|
||||||
progMessage = "Processing"
|
|
||||||
if kodiEpisodes != None:
|
if kodiEpisodes != None:
|
||||||
for KodiItem in kodiEpisodes:
|
for KodiItem in kodiEpisodes:
|
||||||
|
|
||||||
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
|
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
|
||||||
if comparestring1 == comparestring2:
|
if comparestring1 == comparestring2:
|
||||||
matchFound = True
|
matchFound = True
|
||||||
|
break
|
||||||
|
|
||||||
if not matchFound:
|
if not matchFound:
|
||||||
#no match so we have to create it
|
#no match so we have to create it
|
||||||
WriteKodiDB().addEpisodeToKodiLibrary(tvshow,tvshow)
|
WriteKodiDB().addEpisodeToKodiLibrary(tvshow,tvshow)
|
||||||
updateNeeded = True
|
updateNeeded = True
|
||||||
progMessage = "Adding"
|
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
@ -264,7 +275,7 @@ class LibrarySync():
|
||||||
# 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="Adding Episode: " + str(count))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
#initiate library update and wait for finish before processing any updates
|
#initiate library update and wait for finish before processing any updates
|
||||||
|
@ -273,6 +284,11 @@ class LibrarySync():
|
||||||
updateNeeded = False
|
updateNeeded = False
|
||||||
|
|
||||||
#process updates
|
#process updates
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, "Sync DB : Processing Episodes")
|
||||||
|
total = len(latestMBEpisodes) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
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
|
||||||
|
@ -281,31 +297,27 @@ class LibrarySync():
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
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
|
#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"
|
|
||||||
if kodiEpisodes != None:
|
if kodiEpisodes != None:
|
||||||
for KodiItem in kodiEpisodes:
|
for KodiItem in kodiEpisodes:
|
||||||
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
|
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
|
||||||
if comparestring1 == comparestring2:
|
if comparestring1 == comparestring2:
|
||||||
#match found - update episode
|
#match found - update episode
|
||||||
|
#WriteKodiDB().updateEpisodeToKodiLibrary(tvshow,KodiItem,tvshow)
|
||||||
|
#TODO not sure but how to update the show
|
||||||
|
print "TODO: Actual do the update"
|
||||||
|
|
||||||
progMessage = "Updating"
|
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
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="Updating Episode: " + str(count))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -327,7 +339,7 @@ class LibrarySync():
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.update(0, "Sync DB : Processing TV Shows")
|
pDialog.update(0, "Sync DB : Processing TV Shows")
|
||||||
total = len(tvShowData) + 1
|
total = len(tvShowData) + 1
|
||||||
count = 0
|
count = 1
|
||||||
|
|
||||||
for item in tvShowData:
|
for item in tvShowData:
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
|
@ -361,6 +373,9 @@ class LibrarySync():
|
||||||
#TODO --> maybe pull full info only when needed ?
|
#TODO --> maybe pull full info only when needed ?
|
||||||
allEpisodes = list()
|
allEpisodes = list()
|
||||||
|
|
||||||
|
showTotal = len(allTVShows)
|
||||||
|
showCurrent = 1
|
||||||
|
|
||||||
for tvshow in allTVShows:
|
for tvshow in allTVShows:
|
||||||
|
|
||||||
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
||||||
|
@ -370,7 +385,7 @@ class LibrarySync():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.update(0, "Sync DB : Processing Episodes")
|
pDialog.update(0, "Sync DB : Processing Tv Show " + str(showCurrent) + " of " + str(showTotal))
|
||||||
total = len(episodeData) + 1
|
total = len(episodeData) + 1
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
|
@ -407,6 +422,8 @@ class LibrarySync():
|
||||||
pDialog.update(percentage, message=progMessage + " Episode: " + str(count))
|
pDialog.update(percentage, message=progMessage + " Episode: " + str(count))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
showCurrent += 1
|
||||||
|
|
||||||
#initiate library update and wait for finish before processing any updates
|
#initiate library update and wait for finish before processing any updates
|
||||||
if updateNeeded:
|
if updateNeeded:
|
||||||
self.doKodiLibraryUpdate()
|
self.doKodiLibraryUpdate()
|
||||||
|
@ -434,13 +451,11 @@ class LibrarySync():
|
||||||
|
|
||||||
#initiate library clean and wait for finish before processing any updates
|
#initiate library clean and wait for finish before processing any updates
|
||||||
if cleanNeeded:
|
if cleanNeeded:
|
||||||
doKodiLibraryUpdate(True)
|
self.doKodiLibraryUpdate(True)
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except Exception, msg:
|
|
||||||
print "Exception in TvShowsSync --> " + str(msg)
|
|
||||||
finally:
|
finally:
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.close()
|
pDialog.close()
|
||||||
|
@ -463,9 +478,13 @@ class LibrarySync():
|
||||||
def updatePlayCounts(self):
|
def updatePlayCounts(self):
|
||||||
#update all playcounts from MB3 to Kodi library
|
#update all playcounts from MB3 to Kodi library
|
||||||
|
|
||||||
|
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
pDialog = None
|
pDialog = None
|
||||||
|
|
||||||
|
processMovies = True
|
||||||
|
processTvShows = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
enableProgress = False
|
enableProgress = False
|
||||||
if addon.getSetting("enableProgressPlayCountSync") == 'true':
|
if addon.getSetting("enableProgressPlayCountSync") == 'true':
|
||||||
|
@ -560,9 +579,6 @@ class LibrarySync():
|
||||||
pDialog.update(percentage, message="Updating Episode: " + str(count))
|
pDialog.update(percentage, message="Updating Episode: " + str(count))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
except Exception, msg:
|
|
||||||
print "Exception in updatePlaycounts --> " + str(msg)
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.close()
|
pDialog.close()
|
||||||
|
|
Loading…
Reference in a new issue