mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
stop sync if exiting or playback started
This commit is contained in:
parent
f587905d91
commit
46f2a3ffdb
1 changed files with 46 additions and 1 deletions
|
@ -49,6 +49,9 @@ class LibrarySync():
|
||||||
allMovies = list()
|
allMovies = list()
|
||||||
movieData = self.getMovies(True)
|
movieData = self.getMovies(True)
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
if(movieData == None):
|
if(movieData == None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -70,6 +73,9 @@ class LibrarySync():
|
||||||
self.updateMovieToKodiLibrary(item, kodiItem)
|
self.updateMovieToKodiLibrary(item, kodiItem)
|
||||||
progMessage = "Updating"
|
progMessage = "Updating"
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
# 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))
|
||||||
|
@ -81,6 +87,9 @@ class LibrarySync():
|
||||||
allEpisodes = list()
|
allEpisodes = list()
|
||||||
tvShowData = self.getTVShows(True)
|
tvShowData = self.getTVShows(True)
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
if (tvShowData == None):
|
if (tvShowData == None):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -102,6 +111,9 @@ class LibrarySync():
|
||||||
self.updateTVShowToKodiLibrary(item, kodiItem)
|
self.updateTVShowToKodiLibrary(item, kodiItem)
|
||||||
progMessage = "Updating"
|
progMessage = "Updating"
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
# 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))
|
||||||
|
@ -118,6 +130,9 @@ class LibrarySync():
|
||||||
episodeData = self.getEpisodes(tvshow,True)
|
episodeData = self.getEpisodes(tvshow,True)
|
||||||
kodiEpisodes = self.getKodiEpisodes(tvshow)
|
kodiEpisodes = self.getKodiEpisodes(tvshow)
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.update(0, "Sync DB : Processing Episodes")
|
pDialog.update(0, "Sync DB : Processing Episodes")
|
||||||
total = len(episodeData) + 1
|
total = len(episodeData) + 1
|
||||||
|
@ -147,6 +162,9 @@ class LibrarySync():
|
||||||
updateNeeded = True
|
updateNeeded = True
|
||||||
progMessage = "Adding"
|
progMessage = "Adding"
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
# 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))
|
||||||
|
@ -158,6 +176,9 @@ class LibrarySync():
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.update(0, message="Removing Deleted Items")
|
pDialog.update(0, message="Removing Deleted Items")
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
cleanNeeded = False
|
cleanNeeded = False
|
||||||
allLocaldirs, filesMovies = xbmcvfs.listdir(movieLibrary)
|
allLocaldirs, filesMovies = xbmcvfs.listdir(movieLibrary)
|
||||||
allMB3Movies = set(allMovies)
|
allMB3Movies = set(allMovies)
|
||||||
|
@ -166,6 +187,9 @@ class LibrarySync():
|
||||||
self.deleteMovieFromKodiLibrary(dir)
|
self.deleteMovieFromKodiLibrary(dir)
|
||||||
cleanneeded = True
|
cleanneeded = True
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
allLocaldirs, filesTVShows = xbmcvfs.listdir(tvLibrary)
|
allLocaldirs, filesTVShows = xbmcvfs.listdir(tvLibrary)
|
||||||
allMB3TVShows = set(allTVShows)
|
allMB3TVShows = set(allTVShows)
|
||||||
for dir in allLocaldirs:
|
for dir in allLocaldirs:
|
||||||
|
@ -173,6 +197,9 @@ class LibrarySync():
|
||||||
self.deleteTVShowFromKodiLibrary(dir)
|
self.deleteTVShowFromKodiLibrary(dir)
|
||||||
cleanneeded = True
|
cleanneeded = True
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
if cleanNeeded:
|
if cleanNeeded:
|
||||||
xbmc.executebuiltin("CleanLibrary(video)")
|
xbmc.executebuiltin("CleanLibrary(video)")
|
||||||
|
|
||||||
|
@ -201,6 +228,10 @@ class LibrarySync():
|
||||||
|
|
||||||
#process movies
|
#process movies
|
||||||
movieData = self.getMovies(False)
|
movieData = self.getMovies(False)
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
if(movieData == None):
|
if(movieData == None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -224,6 +255,9 @@ class LibrarySync():
|
||||||
if kodiresume != resume:
|
if kodiresume != resume:
|
||||||
self.setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
self.setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
# update progress bar
|
# update progress bar
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
percentage = int(((float(count) / float(totalCount)) * 100))
|
percentage = int(((float(count) / float(totalCount)) * 100))
|
||||||
|
@ -232,6 +266,10 @@ class LibrarySync():
|
||||||
|
|
||||||
#process Tv shows
|
#process Tv shows
|
||||||
tvshowData = self.getTVShows(False)
|
tvshowData = self.getTVShows(False)
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
if (tvshowData == None):
|
if (tvshowData == None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -258,6 +296,9 @@ class LibrarySync():
|
||||||
if kodiresume != resume:
|
if kodiresume != resume:
|
||||||
self.setKodiResumePoint(kodiItem['episodeid'],resume,total,"episode")
|
self.setKodiResumePoint(kodiItem['episodeid'],resume,total,"episode")
|
||||||
|
|
||||||
|
if(self.ShouldStop()):
|
||||||
|
return False
|
||||||
|
|
||||||
# update progress bar
|
# update progress bar
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
percentage = int(((float(count) / float(totalCount)) * 100))
|
percentage = int(((float(count) / float(totalCount)) * 100))
|
||||||
|
@ -960,7 +1001,11 @@ class LibrarySync():
|
||||||
'id' : view.get("Id")})
|
'id' : view.get("Id")})
|
||||||
return collections
|
return collections
|
||||||
|
|
||||||
|
def ShouldStop(self):
|
||||||
|
if(xbmc.Player().isPlaying() or xbmc.abortRequested):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue