[RELEASE] Texture Cache Maintenance utility
Hi,
I've written this script to manager my kodi thumbnails and it does exactly what I want. I hope it will do what you want also.
Brian.

#!/usr/bin/python
# filename: flush.py

# As a safeguard stop kodi before use.

import sqlite3
import sys
import os

# Set up home directory
home = os.getenv("HOME")

count = 0

# Connect sqlite3 to database
try:
conn = sqlite3.connect(home + '/.kodi/userdata/Database/Textures13.db')

choice = conn.execute("SELECT DISTINCT url from texture") # get distinct entries from database
for row in choice: # as a guide to which to flush
print row[0]

category = raw_input("Please select a keyword from above list for which category to flush >>> ")

cursor = conn.execute("SELECT id, url, cachedurl, imagehash, lasthashcheck from texture")
# read database
for row in cursor: # loop through all entries in database
target = row[1] # get url as target
if category in target: # test if target contains our category
record = row[0] # yes, get record id number
print "Deleting record no.", record
conn.execute("DELETE from texture where id=?",(record,)) # delete this entry
conn.commit() # commit change
file = home + '/.kodi/userdata/Thumbnails/' + row[2] # get cachedurl filename
if os.path.exists(file): # make sure it exists
print "Removing file ", file
os.remove(file) # remove file
count += 1 # count how many thumbnails have been removed
print "Number of thumbnails removed ", count

# Failed to open database, report error
except sqlite3.Error as e:
print "Error %s:" % e.args[0]
sys.exit(1)

# That's all folks
finally:
if conn:
conn.close()
Reply


Messages In This Thread
Crash on Gotham on OS X - by desepticon - 2014-05-29, 17:57
RE: [RELEASE] Texture Cache Maintenance utility - by Brian Garratt - 2015-03-05, 14:39
Cleaning - by AleisterHH - 2018-05-28, 22:03
RE: Cleaning - by Milhouse - 2018-05-28, 22:16
qax genre not updated - by Just-Me_A-User - 2018-06-12, 22:06
RE: qax genre not updated - by Milhouse - 2018-06-12, 23:40
Logout Mark Read Team Forum Stats Members Help
[RELEASE] Texture Cache Maintenance utility17