Cache image only when new or modified
Prevent caching image when it is unchanged.
This commit is contained in:
parent
c61a17d48d
commit
56c261279c
1 changed files with 5 additions and 1 deletions
|
@ -775,21 +775,25 @@ class WriteKodiVideoDB():
|
||||||
|
|
||||||
if imageUrl:
|
if imageUrl:
|
||||||
|
|
||||||
|
cacheimage = False
|
||||||
|
|
||||||
cursor.execute("SELECT url FROM art WHERE media_id = ? AND media_type = ? AND type = ?", (kodiId, mediaType, imageType,))
|
cursor.execute("SELECT url FROM art WHERE media_id = ? AND media_type = ? AND type = ?", (kodiId, mediaType, imageType,))
|
||||||
try: # Update the artwork
|
try: # Update the artwork
|
||||||
url = cursor.fetchone()[0]
|
url = cursor.fetchone()[0]
|
||||||
except: # Add the artwork
|
except: # Add the artwork
|
||||||
|
cacheimage = True
|
||||||
self.logMsg("Adding Art Link for kodiId: %s (%s)" % (kodiId, imageUrl), 1)
|
self.logMsg("Adding Art Link for kodiId: %s (%s)" % (kodiId, imageUrl), 1)
|
||||||
query = "INSERT INTO art(media_id, media_type, type, url) values(?, ?, ?, ?)"
|
query = "INSERT INTO art(media_id, media_type, type, url) values(?, ?, ?, ?)"
|
||||||
cursor.execute(query, (kodiId, mediaType, imageType, imageUrl))
|
cursor.execute(query, (kodiId, mediaType, imageType, imageUrl))
|
||||||
else:
|
else:
|
||||||
if url != imageUrl:
|
if url != imageUrl:
|
||||||
|
cacheimage = True
|
||||||
self.logMsg("Updating Art Link for kodiId: %s (%s) -> (%s)" % (kodiId, url, imageUrl), 1)
|
self.logMsg("Updating Art Link for kodiId: %s (%s) -> (%s)" % (kodiId, url, imageUrl), 1)
|
||||||
query = "INSERT INTO art(media_id, media_type, type, url) values(?, ?, ?, ?)"
|
query = "INSERT INTO art(media_id, media_type, type, url) values(?, ?, ?, ?)"
|
||||||
cursor.execute(query, (kodiId, mediaType, imageType, imageUrl))
|
cursor.execute(query, (kodiId, mediaType, imageType, imageUrl))
|
||||||
|
|
||||||
# Cache fanart and poster in Kodi texture cache
|
# Cache fanart and poster in Kodi texture cache
|
||||||
if imageType in ("fanart", "poster"):
|
if cacheimage and imageType in ("fanart", "poster"):
|
||||||
self.textureCache.CacheTexture(imageUrl)
|
self.textureCache.CacheTexture(imageUrl)
|
||||||
|
|
||||||
def setKodiResumePoint(self, fileid, resume_seconds, total_seconds, cursor):
|
def setKodiResumePoint(self, fileid, resume_seconds, total_seconds, cursor):
|
||||||
|
|
Loading…
Reference in a new issue