• 1
  • 169
  • 170
  • 171(current)
  • 172
  • 173
  • 197
[RELEASE] Texture Cache Maintenance utility
Is there anything special that needs to be done if using a central MYSQL server? I run the script with mostly defaults and when cache moveis I get errors such as..

Environment info:
MYSQL DB (same machine as Kodi and the script)
Windows 10

My texturecache config is this...
xbmc.host = localhost
webserver.port = 8080
webserver.username = xxxx
webserver.password = xxxx
download.threads = 40
allow.recacheall=yes
logfile = c:\temp\texturecache.log

ran  .\texturecache.py c movies

then every movies has an error similar to
2018-12-01 08:44:01.634171:MainThread: ERROR ITEM: {4, "movies", "poster", "Zero Dark Thirty", None, None, "C:\Upload\xbmc_videodb_2015-11-22\movies\Zero_Dark_Thirty_2012-poster.jpg", 0, None, 471, False}

I don't know why it has "C:\Upload\xbmc_videodb_2015-11-22" in the path?
Reply
(2018-12-01, 10:58)ScorpioJonesy Wrote: Is there anything special that needs to be done if using a central MYSQL server?

No.

(2018-12-01, 10:58)ScorpioJonesy Wrote: I don't know why it has "C:\Upload\xbmc_videodb_2015-11-22" in the path?

Because that's the artwork path you have in your MySQL video library - presumably that's where you scraped the artwork from, or exported/imported it to/from.

Try running .\texturecache.py jd movies "Zero Dark Thirty" and you'll see the artwork paths being used by the movie. If the paths are incorrect you'll need to fix them - have a look at the mklocal.py link at the foot of the first post as it can help get your artwork back in order.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
(2018-12-01, 20:27)Milhouse Wrote:
(2018-12-01, 10:58)ScorpioJonesy Wrote: Is there anything special that needs to be done if using a central MYSQL server?

No.
(2018-12-01, 10:58)ScorpioJonesy Wrote: I don't know why it has "C:\Upload\xbmc_videodb_2015-11-22" in the path?

Because that's the artwork path you have in your MySQL video library - presumably that's where you scraped the artwork from, or exported/imported it to/from.

Try running .\texturecache.py jd movies "Zero Dark Thirty" and you'll see the artwork paths being used by the movie. If the paths are incorrect you'll need to fix them - have a look at the mklocal.py link at the foot of the first post as it can help get your artwork back in order. 
 Thanks for the info, I did some checking using the script and it seems something had gone wrong with the library so I did a full reset and rescan. All looking good again now.
Reply
(2017-10-29, 17:47)Mr.Floppy Wrote:
(2017-10-15, 06:25)Mr.Floppy Wrote:
(2016-02-02, 16:10)Milhouse Wrote: Ah right, you don't want to execute this script in the context of the Kodi process.

Here's a fix... http://sprunge.us/eLXN

Put this alongside the texturecache.py script, call it shell.py and give it execute permissions - on Linux:
Code:
wget http://sprunge.us/eLXN -O ~/.kodi/userdata/shell.py && chmod +x ~/.kodi/userdata/shell.py

Now your Runscript() call needs to be (note this assumes the texturecache.py script is alongside the shell.py script, otherwise specify the full path to texturecache.py - don't use special://whatever):
Code:
RunScript(special://profile/shell.py,./texturecache.py,c)

For instance to map this to a remote control button:
Code:
<red>XBMC.RunScript(special://profile/shell.py,./texturecache.py,c)</red>

As a bonus you'll get notifications on start and finish, and you won't be able to run multiple instances (which wouldn't be good).      

@milhouse:

While the solution via the shell.py script is working fine on my KODI Krypton v17.4 installations under LibreELEC on my Raspberry Pi and ANDROID box, I can't get it to work on my PC using KODI for windows...

First problem:
As there are no "/var/run/" directories on the KODI installation on my PC running Windows 7, I replaced the line from
pidfile = "/var/run/shellpy.pid"
to
pidfile = "C:\Users\Stefan\AppData\Roaming\KODI\userdata\shellpy.pid"

-> problem solved

Second problem:
Trying to run the script shell.py throws the following excepton in the KODI log:
05:43:21.729 T:2148   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.WindowsError'>
                                            Error Contents: [Error 2] Das System kann die angegebene Datei nicht finden
                                            Traceback (most recent call last):
                                              File "C:\Users\Stefan\AppData\Roaming\Kodi\userdata\shell.py", line 31, in <module>
                                                shellnotify(sys.argv[1:])
                                              File "C:\Users\Stefan\AppData\Roaming\Kodi\userdata\shell.py", line 24, in shellnotify
                                                notify("Starting...", " ".join(args))
                                              File "C:\Users\Stefan\AppData\Roaming\Kodi\userdata\shell.py", line 11, in notify
                                                shellcmd(["kodi-send", "--action", "Notification(%s,%s)" % (header, text)])
                                              File "C:\Users\Stefan\AppData\Roaming\Kodi\userdata\shell.py", line 7, in shellcmd
                                                process = subprocess.Popen(args, stderr=open(os.devnull, 'w'))
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\subprocess.py", line 390, in __init__
                                                errread, errwrite)
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\subprocess.py", line 640, in _execute_child
                                                startupinfo)
                                            WindowsError: [Error 2] Das System kann die angegebene Datei nicht finden
                                            -->End of Python script error


I assume that the "WindowsError: [Error 2] Das System kann die angegebene Datei nicht finden" (translated to english: "The system can't find the specified file") is caused by the missing "kodi-send" command under Windows, right?
I was not able to find an alternative command line tool for windows, but maybe I didn't use the appropriate search terms, since I'm a noob regarding python programming...

So - how could I get a "work-around" for this problem?      

Okay - after having dealt with Python and shell scripting under Windows for quite some time now, I finally found a way to modify the shell.py script so that it works now under this OS, too.

There are some important points to remember:
a) Since Windows (other than Linux) has no built-in Python interpreter and bash shell, you have to install them separately.
b) To avoid any problems with KODI, you have to install "Python 2.x" - "Python 3.x" won't work!
c) The paths to the executable files must be added to the environment variable PATH in Windows.

But don't afraid - this is not complicated at all if you follow my advices:
1. Download and install a "Python 2.x" version from the website under https://www.python.org/downloads/windows/ ; make sure that you enable "Add python.exe to path" in the process of installation!
2. Download and install "Git for windows" (which provides a BASH emulation) from the website under https://git-for-windows.github.io/ ; make sure that you enable "Use Git and optional Unix tools from the Windows Command Prompt" in the process of installation!

And here's the modified shell.py script:
Code:
!/usr/bin/env python
# -*- coding: utf-8 -*-

import os, subprocess, sys, xbmc

def shellcmd(args):
  if sys.argv[1].endswith(".py"):
    command = "python " + " ".join(args)
  elif sys.argv[1].endswith(".sh"):
    command = "sh " + " ".join(args)

  subprocess.call(command, shell=True)

def notify(header, text):
  xbmc.executebuiltin('notification(%s, %s)' % (header, text))

def shellnotify(args):
  os.chdir(os.path.dirname(os.path.realpath(__file__)))
  pidfile = "shellpy.pid"

  if os.path.isfile(pidfile):
   notify("Already running!", file(pidfile, 'r').read())
   sys.exit(1)

  file(pidfile, 'w').write(" ".join(args))

  try:
    notify("Starting...", " ".join(args))
    shellcmd(args)
    notify("Finished", " ".join(args))
  finally:
    os.unlink(pidfile)


shellnotify(sys.argv[1:])

The beauty of this solution is that it will work not only with the Runscript() call of "./texturecache.py", but also with any other shell script; for an example see here: https://forum.kodi.tv/showthread.php?tid...pid2233173

Have fun with it :-)      
@Milhouse:

Since upgrading from KODI v17.6 to KODI v18 (RC2), the solution I posted above doesn't work under Windows 7 anymore, it seems that texturecache.py isn't compatible with this KODI version and OS :-(
The shell.py from above itself does work, I tested it with the following simple shell script callled "test.sh":

#!/bin/bash
echo -en "\007"
c:/Users/Stefan/AppData/Roaming/Kodi/userdata/scripts/texturecache.py volume mute

When calling this example script via shell.py by "RunScript(special://userdata/scripts/shell.py,./test.sh)", I can hear the "beep" sound coming from the first command line, but the second one does nothing (it should mute the volume and invoke the corresponding "muted speaker" symbol on the KODI screen).
Testing the same example under my other KODI 18 RC2 installations using LibreElec on Android TV Box and RaspberryPi, it works without any problems - under KODI v17.6 it worked under Windows 7, too.

Could you please fix it?

Thank you in advance!
Reply
@Mr.Floppy: test calling texturecache.py directly from the command line, maybe you're missing a PATH entry for the Python executable. I'm pretty sure the script works fine on Windows providing your Windows system is configured correctly.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
@Milhouse 

I tested it directly from the command line in windows 7, and it worked, yeah, but I have no clue why it doesn't work directly in KODI 18 RC2 via the "RunScript" method , since it DID work under KODI v17.6 this way and I didn't change anything regarding Windows 7 since then...

Okay, let's try further simple examples:

RunScript(special://userdata/scripts/shell.py,./texturecache.py,volume mute)
-> nothing happens (in KODI v17.6 it worked this way)

But when I use my own python script "test.py"
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import os, sys, time
c = int(sys.argv[1])
for z in range(0,c):
  sys.stdout.write("\a")
  time.sleep(3)

by calling "RunScript(special://userdata/scripts/shell.py,./test.py,6)"
-> it works, I can hear the sound 6 times in total

Any idea?
Reply
Enable the texturecache logfile - that would at least confirm if texturecache.py is running, and if it is it may give a clue why it is not working. However my expectation is that the texturecache.py script is not being run correctly, which may be due to Windows and/or RunScript.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
I enabled logging in the texturecache.cfg, but it doesn't even start logging when using the "RunScript" method! (Running it from the windows 7 command line, however, does create a logfile.)

But maybe I now have got a hint what is going wrong: I put the code from my "test.py" into your "texturecache.py" just to find out why it isn't executed when using the "RunScript" method.

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import os, sys, platform, re, datetime, time
import socket, base64, hashlib
import threading, random
import errno, codecs
import subprocess
import tempfile

for z in range(0,3):
  sys.stdout.write("\a")
  time.sleep(3)

Result: no execution

but when "socket" is removed, it looks like this

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import os, sys, platform, re, datetime, time
import base64, hashlib
import threading, random
import errno, codecs
import subprocess
import tempfile

for z in range(0,3):
  sys.stdout.write("\a")
  time.sleep(3)

Result: it does work!!!!!!!

So I think the issue is related to the use of "import socket" under "KODI 18 for Windows", thus "texturecache.py" needs some modification to work again with the "RunScript" method.

Could you please have a look at it?

Thank you in advance!
Reply
(2018-12-13, 20:17)Mr.Floppy Wrote: So I think the issue is related to the use of "import socket" under "KODI 18 for Windows", thus "texturecache.py" needs some modification to work again with the "RunScript" method.

Could you please have a look at it?

Thank you in advance!

No sorry, pretty sure this is not a texturecache.py issue as the script is working fine from the command line - if anything it's a Kodi on Windows issue, in which case you should open an issue on the Kodi github posting your sample test script with/without import socket. Unfortunately the socket module is pretty crucial to the functionality of texturecache.py and removing it will not be possible.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
I'm very sorry, it was all my fault...

Obviously, I had installed "Python 2.x" in its 32bit version, and because there is only a 32bit version of KODI v17.6, no problems occured.
Then KODI 18 came out, and I chose the first download link (=64bit version), but did forget to remove the 32bit version of "Python 2.x" and replace it with its 64bit version...
After doing so, all is working fine now!
Reply
I am using kodi 18 nightly,

and i ran texturecache.py C recently.

After this, i am missing most of the artwork for my movies, for example posters for 80% of my movies, just have a blank thumbnail.

I tried deleting the Textures13.db file, but its still the same issue.

Can anyone give me some other suggestions on how i can fix this?

Mant thanks for any help!
Br
Patric
Reply
(2019-01-05, 19:31)mrpg Wrote: I am using kodi 18 nightly,

and i ran texturecache.py C recently.

After this, i am missing most of the artwork for my movies, for example posters for 80% of my movies, just have a blank thumbnail.

I tried deleting the Textures13.db file, but its still the same issue.

Can anyone give me some other suggestions on how i can fix this?

Mant thanks for any help!
Br
Patric
Check your Kodi log for errors. If your artwork is remote, check it is still accessible. If artwork has been cached, look in the Thumbnails folder and view some of the cached jpgs outside of Kodi (ie. in a browser, photo/image viewing tool) to make sure they're not corrupt.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
Thanks for the reply,

ok, i see something i do not understand in the logs, as far as i know, i have never asked kodi to save images for anything on my nas.

But its looking for movie posters on an nfs mounted disk (i.e my nas)

13:05:31.901 T:140613692253952   DEBUG: GetImageHash - unable to stat url /data/nas2/Various/Patric/xbmc_videodb_2017-01-27/movies/Austin_Powers:_The_Spy_Who_Shagged_Me_1970-poster.jpg

The xbmc_videodb... folder does not exists in that path , and i would really not want them cached there, prefer they were local on the kodi pc

How can i correct this?

Br
PG
Reply
Worked around it by changing source to "none" and back to "movies" and refreshed the source.
Reply
For version 2.4.8, I used the "c" option to cache all textures, from the output of the command, I saw a lot of images cached and there is no problem reported at the end, but I found the discart and actor image are still being loaded from online by Kodi (it took some time before these image showing). Is this expected?

DEBUG: Caching image 'https://assets.fanart.tv/fanart/movies/269149/moviedisc/zootopia-56bfc33e7cd6f.png' to '6/6e7066a1.png':
DEBUG: cached image 'special://masterprofile/Thumbnails/6/6e7066a1.png' size 720x720

DEBUG: Caching image 'http://image.tmdb.org/t/p/original/mEArEtz9hiSptnllYJvhh0mbp35.jpg' to 'd/de43a668.jpg':
DEBUG: cached image 'special://masterprofile/Thumbnails/d/de43a668.jpg' size 300x450

I run the "P" command to clear the texture and run "c" command again to cache and then run the "p" to see what's non-referenced image in texture cache, just found a lot of discart and actor images in the list, for example:

031496|b/b2ad02e2.png|0720|0720|0001||                   |https://assets.fanart.tv/fanart/movies/315635/moviedisc/spider-man-homecoming-590086b14964f.png

Seems the texturecache tool cached these images successfully, but failed to set them in database, so Kodi has no knowledge about them and download it again from online when they are used.
Reply
  • 1
  • 169
  • 170
  • 171(current)
  • 172
  • 173
  • 197

Logout Mark Read Team Forum Stats Members Help
[RELEASE] Texture Cache Maintenance utility17