wait and check again before running background image cache action

This commit is contained in:
faush01
2019-09-02 14:36:24 +10:00
parent 829dcd1989
commit 77cd94302d
4 changed files with 15 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.embycon"
name="EmbyCon"
version="1.9.30"
version="1.9.31"
provider-name="Team B">
<requires>
<import addon="xbmc.python" version="2.25.0"/>

View File

@@ -34,6 +34,9 @@ class CacheArtwork(threading.Thread):
self.stop_all_activity = False
super(CacheArtwork, self).__init__()
def stop_activity(self):
self.stop_all_activity = True
def run(self):
log.debug("CacheArtwork background thread started")
last_update = 0
@@ -42,15 +45,22 @@ class CacheArtwork(threading.Thread):
latest_content_hash = "never"
check_interval = int(settings.getSetting('cacheImagesOnScreenSaver_interval'))
check_interval = check_interval * 60
monitor = xbmc.Monitor()
while not self.stop_all_activity and not xbmc.abortRequested:
while not self.stop_all_activity and not monitor.abortRequested():
content_hash = home_window.getProperty("embycon_widget_reload")
if (check_interval != 0 and (time.time() - last_update) > check_interval) or (latest_content_hash != content_hash):
log.debug("CacheArtwork background thread - triggered")
if monitor.waitForAbort(10):
break
if self.stop_all_activity or monitor.abortRequested():
break
self.cache_artwork_background()
last_update = time.time()
latest_content_hash = content_hash
xbmc.sleep(1000)
monitor.waitForAbort(1)
log.debug("CacheArtwork background thread exited : stop_all_activity : {0}", self.stop_all_activity)
def delete_cached_images(self, item_id):

View File

@@ -396,7 +396,7 @@ class DownloadUtils:
if not imageTag and not ((art_type == 'Banner' or art_type == 'Art') and parent is True): # ParentTag not passed for Banner and Art
log.debug("No Image Tag for request:{0} item:{1} parent:{2}", art_type, item_type, parent)
# log.debug("No Image Tag for request:{0} item:{1} parent:{2}", art_type, item_type, parent)
return ""
artwork = "%s/emby/Items/%s/Images/%s/%s?Format=original&Tag=%s" % (server, id, art_type, index, imageTag)

View File

@@ -1133,7 +1133,7 @@ class PlaybackService(xbmc.Monitor):
log.debug("Screen Saver Deactivated")
if self.background_image_cache_thread:
self.background_image_cache_thread.stop_all_activity = True
self.background_image_cache_thread.stop_activity()
self.background_image_cache_thread = None
settings = xbmcaddon.Addon()