From 5241baef28e6851cd56ff9932e2cc89654bc52cd Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 13 May 2018 15:22:03 +0200 Subject: [PATCH] Show FanartTV lookup progress in PKC settings --- .../resource.language.en_gb/strings.po | 17 +++++++++++++- resources/lib/artwork.py | 16 +++++++------- resources/lib/library_sync/fanart.py | 22 ++++++++++++++++++- resources/lib/librarysync.py | 14 +++++++++++- resources/settings.xml | 5 +++-- 5 files changed, 61 insertions(+), 13 deletions(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index a73605d8..f52d8dad 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -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" diff --git a/resources/lib/artwork.py b/resources/lib/artwork.py index 3362a472..d50c726e 100644 --- a/resources/lib/artwork.py +++ b/resources/lib/artwork.py @@ -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 diff --git a/resources/lib/library_sync/fanart.py b/resources/lib/library_sync/fanart.py index 13c1e3f2..780db325 100644 --- a/resources/lib/library_sync/fanart.py +++ b/resources/lib/library_sync/fanart.py @@ -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: diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 739c16ec..c6cfa10d 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -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): """ diff --git a/resources/settings.xml b/resources/settings.xml index a094098f..9267b144 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -129,9 +129,10 @@ - - + + +