mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
Sync running check added to Reset Action
This commit is contained in:
parent
f90bda68cf
commit
07ff102a40
2 changed files with 66 additions and 30 deletions
|
@ -37,33 +37,42 @@ class LibrarySync():
|
|||
|
||||
startupDone = WINDOW.getProperty("startup") == "done"
|
||||
syncInstallRunDone = addon.getSetting("SyncInstallRunDone") == "true"
|
||||
WINDOW.setProperty("SyncDatabaseRunning", "true")
|
||||
|
||||
completed = True
|
||||
if(WINDOW.getProperty("SyncDatabaseShouldStop") == "true"):
|
||||
utils.logMsg("Sync Database", "Can not start SyncDatabaseShouldStop=True", 0)
|
||||
return True
|
||||
|
||||
# sync movies
|
||||
if(syncInstallRunDone == False): # on first install run do a full sync with model progress dialog
|
||||
completed = completed and self.TvShowsSync(True, True)
|
||||
completed = completed and self.MoviesSync(True, True)
|
||||
completed = completed and self.MusicVideosSync(True, True)
|
||||
elif(startupDone == False): # on first run after startup do a inc then a full sync
|
||||
self.TvShowsSync(False, False)
|
||||
self.MoviesSync(False, False)
|
||||
self.MusicVideosSync(False, False)
|
||||
self.TvShowsSync(True, False)
|
||||
self.MoviesSync(True, False)
|
||||
self.MusicVideosSync(True, False)
|
||||
else: # on scheduled sync do a full sync
|
||||
self.TvShowsSync(True, False)
|
||||
self.MoviesSync(True, False)
|
||||
self.MusicVideosSync(True, False)
|
||||
try:
|
||||
completed = True
|
||||
|
||||
# set the install done setting
|
||||
if(syncInstallRunDone == False and completed):
|
||||
addon = xbmcaddon.Addon(id='plugin.video.emby') #force a new instance of the addon
|
||||
addon.setSetting("SyncInstallRunDone", "true")
|
||||
# sync movies
|
||||
if(syncInstallRunDone == False): # on first install run do a full sync with model progress dialog
|
||||
completed = completed and self.TvShowsSync(True, True)
|
||||
completed = completed and self.MoviesSync(True, True)
|
||||
completed = completed and self.MusicVideosSync(True, True)
|
||||
elif(startupDone == False): # on first run after startup do a inc then a full sync
|
||||
self.TvShowsSync(False, False)
|
||||
self.MoviesSync(False, False)
|
||||
self.MusicVideosSync(False, False)
|
||||
self.TvShowsSync(True, False)
|
||||
self.MoviesSync(True, False)
|
||||
self.MusicVideosSync(True, False)
|
||||
else: # on scheduled sync do a full sync
|
||||
self.TvShowsSync(True, False)
|
||||
self.MoviesSync(True, False)
|
||||
self.MusicVideosSync(True, False)
|
||||
|
||||
# set prop to show we have run for the first time
|
||||
WINDOW.setProperty("startup", "done")
|
||||
# set the install done setting
|
||||
if(syncInstallRunDone == False and completed):
|
||||
addon = xbmcaddon.Addon(id='plugin.video.emby') #force a new instance of the addon
|
||||
addon.setSetting("SyncInstallRunDone", "true")
|
||||
|
||||
# set prop to show we have run for the first time
|
||||
WINDOW.setProperty("startup", "done")
|
||||
|
||||
finally:
|
||||
WINDOW.setProperty("SyncDatabaseRunning", "false")
|
||||
|
||||
return True
|
||||
|
||||
|
@ -734,9 +743,14 @@ class LibrarySync():
|
|||
processMovies = True
|
||||
processTvShows = True
|
||||
|
||||
if(WINDOW.getProperty("SyncDatabaseShouldStop") == "true"):
|
||||
utils.logMsg("Sync PlayCount", "Can not start SyncDatabaseShouldStop=True", 0)
|
||||
return True
|
||||
|
||||
if(WINDOW.getProperty("updatePlayCounts_Running") == "true"):
|
||||
utils.logMsg("Sync PlayCount", "updatePlayCounts Already Running", 0)
|
||||
return False
|
||||
|
||||
WINDOW.setProperty("updatePlayCounts_Running", "true")
|
||||
|
||||
try:
|
||||
|
@ -977,8 +991,12 @@ class LibrarySync():
|
|||
|
||||
if(xbmc.Player().isPlaying() or xbmc.abortRequested):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
WINDOW = xbmcgui.Window( 10000 )
|
||||
if(WINDOW.getProperty("SyncDatabaseShouldStop") == "true"):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -150,6 +150,23 @@ def removeDirectory(path):
|
|||
xbmcvfs.rmdir(path)
|
||||
|
||||
def reset():
|
||||
|
||||
return_value = xbmcgui.Dialog().yesno("Warning", "Are you sure you want to reset your local database?")
|
||||
if return_value == 0:
|
||||
return
|
||||
|
||||
# first stop any db sync
|
||||
WINDOW = xbmcgui.Window( 10000 )
|
||||
WINDOW.setProperty("SyncDatabaseShouldStop", "true")
|
||||
|
||||
count = 0
|
||||
while(WINDOW.getProperty("SyncDatabaseRunning") == "true"):
|
||||
count += 1
|
||||
if(count > 10):
|
||||
dialog.ok('Warning', 'Could not stop DB sync, you should try again.')
|
||||
return
|
||||
xbmc.sleep(1000)
|
||||
|
||||
# clear video database
|
||||
connection = KodiSQL()
|
||||
cursor = connection.cursor()
|
||||
|
@ -321,5 +338,6 @@ def reset():
|
|||
addon.setSetting("SyncFirstCountsRunDone", "false")
|
||||
|
||||
dialog = xbmcgui.Dialog()
|
||||
dialog.ok('Emby Reset', 'Reset of Emby has completed, please restart.')
|
||||
dialog.ok('Emby Reset', 'Reset of Emby has completed, you need to restart.')
|
||||
xbmc.executebuiltin("RestartApp")
|
||||
|
||||
|
|
Loading…
Reference in a new issue