Improve artwork caching counter in PKC settings
This commit is contained in:
parent
76193329d6
commit
c63adaf2e3
6 changed files with 40 additions and 41 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
<setting label="39020" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=texturecache)" option="close" /> <!-- Cache all images to Kodi texture cache now -->
|
||||
<setting type="sep" />
|
||||
<setting type="lsep" label="30010" /><!-- Approximate progress -->
|
||||
<setting id="caching_major_artwork" label="30011" type="text" default="$ADDON[plugin.video.plexkodiconnect 39310]" enable="false" visible="eq(-8,true)"/><!-- Plex artwork (posters and backgrounds) left to cache: -->
|
||||
<setting id="caching_artwork_count" label="30011" type="text" default="$ADDON[plugin.video.plexkodiconnect 39310]" enable="false" visible="eq(-8,true)"/><!-- Plex artwork (posters and backgrounds) left to cache: -->
|
||||
<setting id="fanarttv_lookups" label="30015" type="text" default="$ADDON[plugin.video.plexkodiconnect 39310]" enable="false" visible="eq(-8,true)"/><!-- Movie and show FanartTV lookups left to do: -->
|
||||
</category>
|
||||
<!--
|
||||
|
|
Loading…
Reference in a new issue