It’s annoying having to delete the entire Textures13.db+Thumbnails folder to try and correct scraping errors and/or corrupted images that just never go away, so I’ve written a very trivial Python script that can be used to interrogate the texture cache database, and can also be used to remove – with absolute precision – those database rows and cached files that relate to problematic artwork.
The script has been tested with local installations of XBMC Frodo on OpenELEC R-Pi and Ubuntu 12.10, and also Windows with Python 2.7.3 running against a remote Frodo installation of XBMC. A separate properties file can be used to specify non-default configurations (see property file details at the end of this post).
This is not an addon, and it requires that the webserver is enabled in XBMC on port 8080 (unless another port is specified in the properties file). It also assumes you are comfortable working at the command line (ssh in Linux, a large CMD window may also work OK for Windows users).
Summary of features
[c, C] Automatically cache missing artwork (c), or with option C force the re-caching of existing artwork by removing first then downloading. Can use multiple threads (default is 2)
[nc] Identify those items that require caching (and would be cached by c option)
[lc, lnc] Same as c and nc, but only considers those media (movies, tvshows/episodes) added since the modification timestamp of the file identified by the property lastrunfile
[p, P] Prune texture cache by identifying (p) or removing (P) accumulated cruft such as image previews, previously deleted movies/tv shows/music whose artwork remains in the texture cache even after cleaning the database. Essentially, remove any cached file that is no longer associated with an entry in the media library and is therefore just wasting disk space
[s, S] Search texture cache database for specific entries and view database content – can help explain reasons for incorrect artwork. S will return only results for items that no longer exist in the Thumbnails folder (but are still in the database).
[x, X] Extract rows from texture cache database, with optional SQL filter. X will return only those database results for items that no longer exist in the Thumbnails folder
[Xd] Remove those rows from the texture cache database that do not have corresponding files in the Thumbnails folder (ie. remove same rows identified by X)
[d] Delete specific database rows and corresponding files from the texture cache using database row identifier (see s/S/x/X)
[r, R] Reverse query cache, identifying “orphaned” files that are no longer referenced in the texture cache database. Use R option to auto-delete these files.
[j, J, jd, Jd] Query media library using JSON API, and export content as JSON (suitable for further external processing). J and Jd will include additional user defined fields; jd and Jd will “decode” (unquote) all URLs
[qa] Perform QA check on media library recently added items, identifying missing properties (eg. plot, mpaa certificate, artwork etc.). Default QA period is previous 30 days. Add property qa.file = yes to verify file exists during QA. Add additional QA fields using qa.art.*, qa.blank.* and qa.zero.* properties.
[qax] Like the qa option, but performs a remove and then rescan of any media found to fail the QA tests
[set, testset] Set values on movie, set, tvshow, episode, musicvideo, artist, album and song. Pass parameters on the command line, or as a batch of data read from stdin. testset will perform a dry-run. See [setting fields](#setting-fields-in-the-media-library) for more details.
[remove] Remove specified library item from media library, ie. remove movie 123
[imdb] Update IMDb fields on movies and tvshows. Pipe output into set option to apply changes to the media library using JSON. Uses http://www.omdbapi.com to query latest IMDb details based on imdbnumber (movies) or title and season/pisode # (tvshows). Movies without imdbnumber will not be updated. Specify movie fields to be updated with the property @imdb.fields.movies from the following: top250, title, rating, votes, year, runtime, genre, plot and plotoutline – the default value is: rating, votes, top250. Specify tvshow fields to be updated with the property @imdb.fields.tvshows from the following: title, rating, votes, year, runtime, genre, plot and plotoutline. Specify additional fields to the default by prefixing the list with +, eg. @imdb.fields.movies=+year,genre to update movie ratings, votes, top250, year and genre. See log for old/new values. See announcement for further important details.
[purge hashed|unhashed|all] Delete cached artwork containing specified patterns, with or without lasthashcheck, or if it doesn’t matter all eg. purge unhashed youtube iplayer imdb.com
[purgetest hashed|unhashed|all] Dry-run version of purge – will show what would be removed during an actual purge
[watched] Backup and restore movie and tvshow watched lists to a text file. Watched list will be restored keeping more recent playcount, lastplayed and resume points unless property watched.overwrite=yes is specified, in which case the watched list will be restored exactly as per the backup.
[duplicates] List movies that appear more than once in the media library with the same imdb number
[missing] Locate media files missing from the specified media library and source label, eg. missing movies “My Movies”
[ascan, vscan] Initiate audio/video library scan, either entire library or a specific path (see sources). The exit status is the number of items added during each scan, ie. 0 or +n.
[aclean, vclean] Clean audio/video library
[directory] Obtain directory listing for a specific path (see sources)
[sources] List of sources for a specific media class (video, music, pictures, files, programs)
[status] Display status of client – ScreenSaver active, IsIdle (default period 600 seconds, or user specified) and active Player type (audio or video), plus title of any media currently being played.
[monitor] Display client event notifications as they occur
[power] Set power state of client – suspend, hibernate, shutdown or reboot
[wake] Use Wake Over LAN to wake a suspended/hibernating remote client. Specify the MAC address of the remote client in the network.mac property (ie. network.mac=xx:xx:xx:xx:xx:xx). When the client is no longer required, suspend or hibernate it with the relevant power option
[exec, execw] Execute the specified addon, with optional parameters. eg. exec script.artwork.downloader silent=true mediatype=tvshow. Use execw to wait, but this rarely has any effect (possibly not implemented by JSON?)
[setsetting] Set the value of the named setting, eg. setsetting locale.language English
[getsetting] Get the current value of the named setting, eg. getsetting locale.language
[getsettings] View details of all settings, or those where pattern is contained within id, eg. getsettings debug to view details of all debug-related settings
[debugon, debugoff] Enable/Disable debugging
[play, playw] Play specified item (local file, playlist, internet stream etc.), optionally waiting until playback is ended
[stop] Stop playback
[pause] Toggle pause/playback of currently playing media
[config] View current configuration
[version] View current installed version
[update] Manually update to latest available version if not already installed. Only required if checkupdate or autoupdate properties are set to no as by default the script will automatically update itself (if required) to the latest version whenever it is executed.
For instructions on how to run a Python script, see here.
Windows users will need to install Python 2.7.x or Python 3.3.x, if not already installed (see how-to).
Download the single Python script file – use “Save as” in your browser – from github. A default properties file is available on github, rename this to texturecache.cfg in order to use it, although in many cases it’s not required and should just be considered a template – pick and choose what options you wish to override.