diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po
index f52d8dad..9c95570c 100644
--- a/resources/language/resource.language.en_gb/strings.po
+++ b/resources/language/resource.language.en_gb/strings.po
@@ -68,7 +68,7 @@ msgstr ""
# PKC settings - Artwork
msgctxt "#30011"
-msgid "Plex artwork (posters and backgrounds) left to cache:"
+msgid "Artwork left to cache:"
msgstr ""
# Button text
diff --git a/resources/lib/artwork.py b/resources/lib/artwork.py
index 8842162e..68900baf 100644
--- a/resources/lib/artwork.py
+++ b/resources/lib/artwork.py
@@ -54,6 +54,8 @@ class Image_Cache_Thread(Thread):
suspended = self.suspended
queue = self.queue
sleep_between = self.sleep_between
+ counter = 0
+ set_zero = False
while not stopped():
# In the event the server goes offline
while suspended():
@@ -63,21 +65,25 @@ class Image_Cache_Thread(Thread):
LOG.info("---===### Stopped Image_Cache_Thread ###===---")
return
sleep(1000)
+ # Update the caching state in the PKC settings. Avoid saving '0'
+ counter += 1
+ if counter > 10:
+ counter = 0
+ length = queue.qsize()
+ if not set_zero:
+ settings('caching_artwork_count', value=str(length))
+ set_zero = False if length else True
+ elif length:
+ settings('caching_artwork_count', value=str(length))
+ set_zero = False
+
try:
url = queue.get(block=False)
except Empty:
sleep(1000)
continue
if isinstance(url, ArtworkSyncMessage):
- if url.artwork_counter is not None:
- if url.artwork_counter == 0:
- # Done caching, show this in the PKC settings, too
- settings('caching_major_artwork', value=lang(30069))
- LOG.info('Done caching major images!')
- else:
- settings('caching_major_artwork',
- value=str(url.artwork_counter))
- if url.message and state.IMAGE_SYNC_NOTIFICATIONS:
+ if state.IMAGE_SYNC_NOTIFICATIONS:
dialog('notification',
heading=lang(29999),
message=url.message,
@@ -168,24 +174,18 @@ class Artwork():
if not artworks_to_cache:
LOG.info('Caching of major images to Kodi texture cache done')
# Set to "None"
- settings('caching_major_artwork', value=lang(30069))
+ settings('caching_artwork_count', value=lang(30069))
return
length = len(artworks_to_cache)
LOG.info('Caching has not been completed - caching %s major images',
length)
- settings('caching_major_artwork', value=str(length))
+ settings('caching_artwork_count', value=str(length))
# Caching %s Plex images
- self.queue.put(ArtworkSyncMessage(message=lang(30006) % length,
- artwork_counter=length))
+ self.queue.put(ArtworkSyncMessage(lang(30006) % length))
for i, url in enumerate(artworks_to_cache):
self.queue.put(url[0])
- if (length - i) % 10 == 0:
- # Update the PKC settings for artwork caching progress
- msg = ArtworkSyncMessage(artwork_counter=length - i)
- self.queue.put(msg)
# Plex image caching done
- self.queue.put(ArtworkSyncMessage(message=lang(30007),
- artwork_counter=0))
+ self.queue.put(ArtworkSyncMessage(lang(30007)))
def fullTextureCacheSync(self):
"""
@@ -343,6 +343,5 @@ class ArtworkSyncMessage(object):
"""
Put in artwork queue to display the message as a Kodi notification
"""
- def __init__(self, message=None, artwork_counter=None):
+ def __init__(self, message):
self.message = message
- self.artwork_counter = artwork_counter
diff --git a/resources/lib/library_sync/fanart.py b/resources/lib/library_sync/fanart.py
index 780db325..9231af86 100644
--- a/resources/lib/library_sync/fanart.py
+++ b/resources/lib/library_sync/fanart.py
@@ -49,6 +49,8 @@ class ThreadedProcessFanart(Thread):
stopped = self.stopped
suspended = self.suspended
queue = self.queue
+ counter = 0
+ set_zero = False
while not stopped():
# In the event the server goes offline
while suspended():
@@ -58,6 +60,18 @@ class ThreadedProcessFanart(Thread):
LOG.info("---===### Stopped FanartSync ###===---")
return
sleep(1000)
+ # Update the caching state in the PKC settings. Avoid saving '0'
+ counter += 1
+ if counter > 10:
+ counter = 0
+ length = queue.qsize()
+ if not set_zero:
+ settings('fanarttv_lookups', value=str(length))
+ set_zero = False if length else True
+ elif length:
+ settings('fanarttv_lookups', value=str(length))
+ set_zero = False
+
# grabs Plex item from queue
try:
item = queue.get(block=False)
@@ -66,15 +80,7 @@ class ThreadedProcessFanart(Thread):
continue
if isinstance(item, ArtworkSyncMessage):
- if item.artwork_counter is not None:
- if item.artwork_counter == 0:
- # Done caching, show this in the PKC settings, too
- settings('fanarttv_lookups', value=lang(30069))
- LOG.info('Done caching major images!')
- else:
- settings('fanarttv_lookups',
- value=str(item.artwork_counter))
- if item.message and state.IMAGE_SYNC_NOTIFICATIONS:
+ if state.IMAGE_SYNC_NOTIFICATIONS:
dialog('notification',
heading=lang(29999),
message=item.message,
diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py
index 1d3b75e0..d2fa81fd 100644
--- a/resources/lib/librarysync.py
+++ b/resources/lib/librarysync.py
@@ -1390,21 +1390,15 @@ class LibrarySync(Thread):
# Shuffle the list to not always start out identically
shuffle(items)
# Checking FanartTV for %s items
- self.fanartqueue.put(artwork.ArtworkSyncMessage(
- message=lang(30018) % len(items), artwork_counter=len(items)))
+ self.fanartqueue.put(artwork.ArtworkSyncMessage(lang(30018) % len(items)))
for i, item in enumerate(items):
self.fanartqueue.put({
'plex_id': item['plex_id'],
'plex_type': item['plex_type'],
'refresh': refresh
})
- if (len(items) - i) % 10 == 0:
- # Update the PKC settings for fanart.tv lookup
- msg = artwork.ArtworkSyncMessage(artwork_counter=len(items) - i)
- self.fanartqueue.put(msg)
# FanartTV lookup completed
- self.fanartqueue.put(artwork.ArtworkSyncMessage(message=lang(30019),
- artwork_counter=0))
+ self.fanartqueue.put(artwork.ArtworkSyncMessage(lang(30019)))
def triage_lib_scans(self):
"""
diff --git a/resources/lib/utils.py b/resources/lib/utils.py
index f7a3e2ac..82225c26 100644
--- a/resources/lib/utils.py
+++ b/resources/lib/utils.py
@@ -436,7 +436,7 @@ def wipe_database():
connection.commit()
cursor.close()
# Reset the artwork sync status in the PKC settings
- settings('caching_major_artwork', value=language(39310))
+ settings('caching_artwork_count', value=language(39310))
settings('fanarttv_lookups', value=language(39310))
# reset the install run flag
settings('SyncInstallRunDone', value="false")
diff --git a/resources/settings.xml b/resources/settings.xml
index 9267b144..b4479b89 100644
--- a/resources/settings.xml
+++ b/resources/settings.xml
@@ -131,7 +131,7 @@
-
+