mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
fix texture cache stuff
This commit is contained in:
parent
d617aa13ac
commit
feb6c73fc3
2 changed files with 28 additions and 21 deletions
|
@ -3,11 +3,11 @@
|
|||
#################################################################################################
|
||||
|
||||
|
||||
import xbmc
|
||||
import xbmcaddon
|
||||
import xbmc, xbmcaddon, xbmcvfs
|
||||
import json
|
||||
import requests
|
||||
import urllib
|
||||
import os
|
||||
|
||||
import Utils as utils
|
||||
|
||||
|
@ -42,15 +42,38 @@ class TextureCache():
|
|||
def FullTextureCacheSync(self):
|
||||
#this method can be called from the plugin to sync all Kodi textures to the texture cache.
|
||||
#Warning: this means that every image will be cached locally, this takes diskspace!
|
||||
|
||||
#remove all existing textures first
|
||||
path = "special://thumbnails/"
|
||||
if xbmcvfs.exists(path):
|
||||
allDirs, allFiles = xbmcvfs.listdir(path)
|
||||
for dir in allDirs:
|
||||
allDirs, allFiles = xbmcvfs.listdir(path+dir)
|
||||
for file in allFiles:
|
||||
xbmcvfs.delete(os.path.join(path+dir,file))
|
||||
|
||||
textureconnection = utils.KodiSQL("texture")
|
||||
texturecursor = textureconnection.cursor()
|
||||
texturecursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"')
|
||||
rows = texturecursor.fetchall()
|
||||
for row in rows:
|
||||
tableName = row[0]
|
||||
if(tableName != "version"):
|
||||
texturecursor.execute("DELETE FROM " + tableName)
|
||||
textureconnection.commit()
|
||||
texturecursor.close()
|
||||
|
||||
|
||||
#cache all entries in video DB
|
||||
connection = utils.KodiSQL("video")
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT url FROM art")
|
||||
result = cursor.fetchall()
|
||||
for url in result:
|
||||
self.CacheTexture(url[0])
|
||||
|
||||
cursor.close()
|
||||
|
||||
#cache all entries in music DB
|
||||
connection = utils.KodiSQL("music")
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT url FROM art")
|
||||
|
@ -74,20 +97,6 @@ class TextureCache():
|
|||
#extreme short timeouts so we will have a exception, but we don't need the result so pass
|
||||
pass
|
||||
|
||||
def refreshFanart(self,url):
|
||||
connection = utils.KodiSQL("texture")
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT cachedurl FROM texture WHERE url = ?", (url,))
|
||||
result = cursor.fetchone()
|
||||
if result:
|
||||
result = result[0]
|
||||
cursor.execute("DELETE FROM texture WHERE cachedurl = ?", (result,))
|
||||
connection.commit()
|
||||
cursor.close()
|
||||
else:
|
||||
cursor.close()
|
||||
self.CacheTexture(url)
|
||||
|
||||
|
||||
def setKodiWebServerDetails(self):
|
||||
# Get the Kodi webserver details - used to set the texture cache
|
||||
|
|
|
@ -792,10 +792,8 @@ class WriteKodiVideoDB():
|
|||
cursor.execute("UPDATE art set url = ? WHERE media_id = ? AND media_type = ? AND type = ?", (imageUrl, kodiId, mediaType, imageType))
|
||||
|
||||
#cache fanart and poster in Kodi texture cache
|
||||
if "fanart" in imageType:
|
||||
if "fanart" in imageType or "poster" in imageType:
|
||||
utils.logMsg("ArtworkSync", "Adding or Updating Fanart: %s" % imageUrl)
|
||||
self.textureCache.refreshFanart(imageUrl)
|
||||
elif "poster" in imageType:
|
||||
self.textureCache.CacheTexture(imageUrl)
|
||||
|
||||
def setKodiResumePoint(self, fileid, resume_seconds, total_seconds, cursor):
|
||||
|
|
Loading…
Reference in a new issue