Show FanartTV lookup progress in PKC settings

This commit is contained in:
croneter 2018-05-13 15:22:03 +02:00
parent f8560aec4d
commit 5241baef28
5 changed files with 61 additions and 13 deletions

View file

@ -63,7 +63,7 @@ msgstr ""
# PKC settings - Artwork
msgctxt "#30010"
msgid "Approximate caching progress"
msgid "Approximate progress"
msgstr ""
# PKC settings - Artwork
@ -85,6 +85,11 @@ msgctxt "#30014"
msgid "Connection"
msgstr ""
# PKC settings - Artwork
msgctxt "#30015"
msgid "Movie and show FanartTV lookups left to do:"
msgstr ""
msgctxt "#30016"
msgid "Device Name"
msgstr ""
@ -94,6 +99,16 @@ msgctxt "#30017"
msgid "Unauthorized for PMS"
msgstr ""
# Sync notification displayed for the number of fanart.tv lookups left
msgctxt "#30018"
msgid "Checking FanartTV for %s items"
msgstr ""
# Sync notification displayed when FanartTV lookup is completed
msgctxt "#30019"
msgid "FanartTV lookup completed"
msgstr ""
# PKC settings category
msgctxt "#30022"
msgid "Advanced"

View file

@ -69,14 +69,14 @@ class Image_Cache_Thread(Thread):
sleep(1000)
continue
if isinstance(url, ArtworkSyncMessage):
if url.major_artwork_counter is not None:
if url.major_artwork_counter == 0:
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.major_artwork_counter))
value=str(url.artwork_counter))
if url.message and state.IMAGE_SYNC_NOTIFICATIONS:
dialog('notification',
heading=lang(29999),
@ -176,16 +176,16 @@ class Artwork():
settings('caching_major_artwork', value=str(length))
# Caching %s Plex images
self.queue.put(ArtworkSyncMessage(message=lang(30006) % length,
major_artwork_counter=length))
artwork_counter=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(major_artwork_counter=length - i)
msg = ArtworkSyncMessage(artwork_counter=length - i)
self.queue.put(msg)
# Plex image caching done
self.queue.put(ArtworkSyncMessage(message=lang(30007),
major_artwork_counter=0))
artwork_counter=0))
def fullTextureCacheSync(self):
"""
@ -343,6 +343,6 @@ class ArtworkSyncMessage(object):
"""
Put in artwork queue to display the message as a Kodi notification
"""
def __init__(self, message=None, major_artwork_counter=None):
def __init__(self, message=None, artwork_counter=None):
self.message = message
self.major_artwork_counter = major_artwork_counter
self.artwork_counter = artwork_counter

View file

@ -5,10 +5,12 @@ from Queue import Empty
from xbmc import sleep
from utils import thread_methods
from utils import thread_methods, settings, language as lang, dialog
import plexdb_functions as plexdb
import itemtypes
from artwork import ArtworkSyncMessage
import variables as v
import state
###############################################################################
@ -63,6 +65,24 @@ class ThreadedProcessFanart(Thread):
sleep(200)
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:
dialog('notification',
heading=lang(29999),
message=item.message,
icon='{plex}',
sound=False)
queue.task_done()
continue
LOG.debug('Get additional fanart for Plex id %s', item['plex_id'])
with getattr(itemtypes,
v.ITEMTYPE_FROM_PLEXTYPE[item['plex_type']])() as item_type:

View file

@ -1388,14 +1388,26 @@ class LibrarySync(Thread):
items.extend(plex_db.itemsByType(plex_type))
LOG.info('Trying to get ALL additional fanart for %s items',
len(items))
if not items:
return
# Shuffle the list to not always start out identically
shuffle(items)
for item in items:
# Checking FanartTV for %s items
self.fanartqueue.put(artwork.ArtworkSyncMessage(
message=lang(30018) % len(items), artwork_counter=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))
def triage_lib_scans(self):
"""

View file

@ -129,9 +129,10 @@
<setting id="imageSyncNotifications" label="30008" type="bool" default="true" /><!-- Enable notifications for image caching -->
<setting id="imageSyncDuringPlayback" label="30009" type="bool" default="true" /><!-- Enable image caching during Kodi playback (restart Kodi!) -->
<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" visible="eq(-6,true)" />
<setting type="lsep" label="30010" visible="eq(-7,true)" /><!-- Approximate caching progress -->
<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="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 label="30235" visible="false">