Fix setting to cache all textures to Kodi

This commit is contained in:
tomkat83 2016-09-17 14:48:40 +02:00
parent ca6bb4e8ca
commit 703f2fb37d
5 changed files with 13 additions and 42 deletions

View file

@ -172,8 +172,7 @@ class Main():
utils.window('plex_runLibScan', value="full")
elif mode == "texturecache":
import artwork
artwork.Artwork().fullTextureCacheSync()
utils.window('plex_runLibScan', value='del_textures')
else:
entrypoint.doMainListing()

View file

@ -453,7 +453,7 @@
<!-- Plex Artwork.py -->
<string id="39250">Running the image cache process can take some time. Are you sure you want continue?</string>
<string id="39250">Running the image cache process can take some time. It will happen in the background. Are you sure you want continue?</string>
<string id="39251">Reset all existing cache data first?</string>
<!-- Plex PlexAPI.py -->

View file

@ -391,7 +391,7 @@
<!-- Plex Artwork.py -->
<string id="39250">Alle Plex Bilder in Kodi zwischenzuspeichern kann sehr lange dauern. Möchten Sie wirklich fortfahren?</string>
<string id="39250">Alle Plex Bilder in Kodi zwischenzuspeichern kann lange dauern. Es wird im Hintergrund stattfinden. Möchten Sie wirklich fortfahren?</string>
<string id="39251">Sollen erst alle bestehenden Bilder im Cache gelöscht werden?</string>
<!-- Plex PlexAPI.py -->

View file

@ -191,7 +191,7 @@ class Image_Cache_Thread(Thread):
break
queue.task_done()
# Sleep for a bit to reduce CPU strain
xbmc.sleep(20)
xbmc.sleep(50)
log.info("---===### Stopped Image_Cache_Thread ###===---")
@ -214,9 +214,6 @@ class Artwork():
log.info("Doing Image Cache Sync")
pdialog = xbmcgui.DialogProgress()
pdialog.create("PlexKodiConnect", "Image Cache Sync")
# ask to rest all existing or not
if xbmcgui.Dialog().yesno(
"Image Texture Cache", lang(39251), ""):
@ -256,53 +253,22 @@ class Artwork():
cursor.execute("SELECT url FROM art WHERE media_type != 'actor'")
result = cursor.fetchall()
total = len(result)
log.info("Image cache sync about to process %s images" % total)
log.info("Image cache sync about to process %s video images" % total)
connection.close()
count = 0
for url in result:
if pdialog.iscanceled():
break
percentage = int((float(count) / float(total))*100)
message = "%s of %s (%s)" % (count, total, self.imageCacheThreads)
pdialog.update(percentage, "%s %s" % (lang(33045), message))
self.cacheTexture(url[0])
count += 1
# Cache all entries in music DB
connection = kodiSQL('music')
cursor = connection.cursor()
cursor.execute("SELECT url FROM art")
result = cursor.fetchall()
total = len(result)
log.info("Image cache sync about to process %s images" % total)
log.info("Image cache sync about to process %s music images" % total)
connection.close()
count = 0
for url in result:
if pdialog.iscanceled():
break
percentage = int((float(count) / float(total))*100)
message = "%s of %s" % (count, total)
pdialog.update(percentage, "%s %s" % (lang(33045), message))
self.cacheTexture(url[0])
count += 1
pdialog.update(100, "%s %s"
% (lang(33046), len(self.imageCacheThreads)))
log.info("Waiting for all threads to exit")
while len(self.imageCacheThreads):
with self.lock:
for thread in self.imageCacheThreads:
if thread.is_finished:
self.imageCacheThreads.remove(thread)
pdialog.update(100, "%s %s"
% (lang(33046), len(self.imageCacheThreads)))
log.info("Waiting for all threads to exit: %s"
% len(self.imageCacheThreads))
xbmc.sleep(500)
pdialog.close()
log.info('Done throwing URLs to art download daemon')
def cacheTexture(self, url):
# Cache a single image url to the texture cache

View file

@ -1803,6 +1803,12 @@ class LibrarySync(Thread):
line1=lang(39223),
nolabel=lang(39224),
yeslabel=lang(39225)))
elif window('plex_runLibScan') == 'del_textures':
window('plex_runLibScan', clear=True)
window('plex_dbScan', value="true")
import artwork
artwork.Artwork().fullTextureCacheSync()
window('plex_dbScan', clear=True)
else:
now = getUnixTimestamp()
if (now - lastSync > fullSyncInterval and