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
|
# PKC settings - Artwork
|
||||||
msgctxt "#30011"
|
msgctxt "#30011"
|
||||||
msgid "Plex artwork (posters and backgrounds) left to cache:"
|
msgid "Artwork left to cache:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
# Button text
|
# Button text
|
||||||
|
|
|
@ -54,6 +54,8 @@ class Image_Cache_Thread(Thread):
|
||||||
suspended = self.suspended
|
suspended = self.suspended
|
||||||
queue = self.queue
|
queue = self.queue
|
||||||
sleep_between = self.sleep_between
|
sleep_between = self.sleep_between
|
||||||
|
counter = 0
|
||||||
|
set_zero = False
|
||||||
while not stopped():
|
while not stopped():
|
||||||
# In the event the server goes offline
|
# In the event the server goes offline
|
||||||
while suspended():
|
while suspended():
|
||||||
|
@ -63,21 +65,25 @@ class Image_Cache_Thread(Thread):
|
||||||
LOG.info("---===### Stopped Image_Cache_Thread ###===---")
|
LOG.info("---===### Stopped Image_Cache_Thread ###===---")
|
||||||
return
|
return
|
||||||
sleep(1000)
|
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:
|
try:
|
||||||
url = queue.get(block=False)
|
url = queue.get(block=False)
|
||||||
except Empty:
|
except Empty:
|
||||||
sleep(1000)
|
sleep(1000)
|
||||||
continue
|
continue
|
||||||
if isinstance(url, ArtworkSyncMessage):
|
if isinstance(url, ArtworkSyncMessage):
|
||||||
if url.artwork_counter is not None:
|
if state.IMAGE_SYNC_NOTIFICATIONS:
|
||||||
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:
|
|
||||||
dialog('notification',
|
dialog('notification',
|
||||||
heading=lang(29999),
|
heading=lang(29999),
|
||||||
message=url.message,
|
message=url.message,
|
||||||
|
@ -168,24 +174,18 @@ class Artwork():
|
||||||
if not artworks_to_cache:
|
if not artworks_to_cache:
|
||||||
LOG.info('Caching of major images to Kodi texture cache done')
|
LOG.info('Caching of major images to Kodi texture cache done')
|
||||||
# Set to "None"
|
# Set to "None"
|
||||||
settings('caching_major_artwork', value=lang(30069))
|
settings('caching_artwork_count', value=lang(30069))
|
||||||
return
|
return
|
||||||
length = len(artworks_to_cache)
|
length = len(artworks_to_cache)
|
||||||
LOG.info('Caching has not been completed - caching %s major images',
|
LOG.info('Caching has not been completed - caching %s major images',
|
||||||
length)
|
length)
|
||||||
settings('caching_major_artwork', value=str(length))
|
settings('caching_artwork_count', value=str(length))
|
||||||
# Caching %s Plex images
|
# Caching %s Plex images
|
||||||
self.queue.put(ArtworkSyncMessage(message=lang(30006) % length,
|
self.queue.put(ArtworkSyncMessage(lang(30006) % length))
|
||||||
artwork_counter=length))
|
|
||||||
for i, url in enumerate(artworks_to_cache):
|
for i, url in enumerate(artworks_to_cache):
|
||||||
self.queue.put(url[0])
|
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
|
# Plex image caching done
|
||||||
self.queue.put(ArtworkSyncMessage(message=lang(30007),
|
self.queue.put(ArtworkSyncMessage(lang(30007)))
|
||||||
artwork_counter=0))
|
|
||||||
|
|
||||||
def fullTextureCacheSync(self):
|
def fullTextureCacheSync(self):
|
||||||
"""
|
"""
|
||||||
|
@ -343,6 +343,5 @@ class ArtworkSyncMessage(object):
|
||||||
"""
|
"""
|
||||||
Put in artwork queue to display the message as a Kodi notification
|
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.message = message
|
||||||
self.artwork_counter = artwork_counter
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ class ThreadedProcessFanart(Thread):
|
||||||
stopped = self.stopped
|
stopped = self.stopped
|
||||||
suspended = self.suspended
|
suspended = self.suspended
|
||||||
queue = self.queue
|
queue = self.queue
|
||||||
|
counter = 0
|
||||||
|
set_zero = False
|
||||||
while not stopped():
|
while not stopped():
|
||||||
# In the event the server goes offline
|
# In the event the server goes offline
|
||||||
while suspended():
|
while suspended():
|
||||||
|
@ -58,6 +60,18 @@ class ThreadedProcessFanart(Thread):
|
||||||
LOG.info("---===### Stopped FanartSync ###===---")
|
LOG.info("---===### Stopped FanartSync ###===---")
|
||||||
return
|
return
|
||||||
sleep(1000)
|
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
|
# grabs Plex item from queue
|
||||||
try:
|
try:
|
||||||
item = queue.get(block=False)
|
item = queue.get(block=False)
|
||||||
|
@ -66,15 +80,7 @@ class ThreadedProcessFanart(Thread):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(item, ArtworkSyncMessage):
|
if isinstance(item, ArtworkSyncMessage):
|
||||||
if item.artwork_counter is not None:
|
if state.IMAGE_SYNC_NOTIFICATIONS:
|
||||||
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:
|
|
||||||
dialog('notification',
|
dialog('notification',
|
||||||
heading=lang(29999),
|
heading=lang(29999),
|
||||||
message=item.message,
|
message=item.message,
|
||||||
|
|
|
@ -1390,21 +1390,15 @@ class LibrarySync(Thread):
|
||||||
# Shuffle the list to not always start out identically
|
# Shuffle the list to not always start out identically
|
||||||
shuffle(items)
|
shuffle(items)
|
||||||
# Checking FanartTV for %s items
|
# Checking FanartTV for %s items
|
||||||
self.fanartqueue.put(artwork.ArtworkSyncMessage(
|
self.fanartqueue.put(artwork.ArtworkSyncMessage(lang(30018) % len(items)))
|
||||||
message=lang(30018) % len(items), artwork_counter=len(items)))
|
|
||||||
for i, item in enumerate(items):
|
for i, item in enumerate(items):
|
||||||
self.fanartqueue.put({
|
self.fanartqueue.put({
|
||||||
'plex_id': item['plex_id'],
|
'plex_id': item['plex_id'],
|
||||||
'plex_type': item['plex_type'],
|
'plex_type': item['plex_type'],
|
||||||
'refresh': refresh
|
'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
|
# FanartTV lookup completed
|
||||||
self.fanartqueue.put(artwork.ArtworkSyncMessage(message=lang(30019),
|
self.fanartqueue.put(artwork.ArtworkSyncMessage(lang(30019)))
|
||||||
artwork_counter=0))
|
|
||||||
|
|
||||||
def triage_lib_scans(self):
|
def triage_lib_scans(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -436,7 +436,7 @@ def wipe_database():
|
||||||
connection.commit()
|
connection.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
# Reset the artwork sync status in the PKC settings
|
# 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))
|
settings('fanarttv_lookups', value=language(39310))
|
||||||
# reset the install run flag
|
# reset the install run flag
|
||||||
settings('SyncInstallRunDone', value="false")
|
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 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="sep" />
|
||||||
<setting type="lsep" label="30010" /><!-- Approximate progress -->
|
<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: -->
|
<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>
|
</category>
|
||||||
<!--
|
<!--
|
||||||
|
|
Loading…
Reference in a new issue