Jump to content

How to: Precache images using texturecache.py


xnappo

Recommended Posts

xnappo

The below information is no longer needed after version 1.0.04:

@marcelveldt's new features in the addon address both problems mentioned below

 

#1 is addressed by the new menu feature 'Cache all images to Kodi Texture cache'.  This takes a while, but only needs to be done once.

 

#2 is handled by the new settings option 'Auto add images to Kodi Texture cache' - which is on by default.

 

So.. No more need for texturecache.py!

 

---------------------------------------------------

 

Kodi uses a local database to cache images to make browsing faster.

 

When you first sync Emby for Kodi, all the images are of course still on the server.

 

This causes two problems:

1. Browsing will be slow, particularly on low end devices

2. Some skins that make use of the local image database will not work correctly (showing black backdrops for instance)

 

To resolve this, you can run a tool called 'texturecache.py'.

 

This is a very powerful tool, and you can find the full documentation here:

http://forum.kodi.tv/showthread.php?tid=158373

 

However this post is intended JUST to get the images cached for Emby for Kodi.

 

Steps:

 

1. Go into Kodi and go to System->Sevices->Webserver and make sure that 'Allow control of Kodi via HTTP' is on.  Also make note of the Port - the default is 8080 - but I already had something on that port so changed it to 89.

556367ddb41f6_web.jpg

 

2. Go into Kodi and go to System->Sevices->Remote control and make sure that BOTH 'Allow programs on this system to control Kodi' AND 'Allow programs on other systems to control Kodi' are ON.

556368372e83d_remote.png

 

3. Exit Kodi and then start it again.

 

4. If you are a Linux/Mac user skip to Step 6.

 

5. Download and Install Python from here: https://www.python.org/ftp/python/2.7.10/python-2.7.10.msi

 

6. Download the texturecache.py script from here:https://raw.github.com/MilhouseVH/texturecache.py/master/texturecache.py

 

7. Put texturecache.py in a convenient path to get to from a command prompt.  On Windows I just stuck it in c:\Python26 - on Linux/Max your home directory is fine.

 

8. Open notepad or any text editor, and make a file with these contents:

webserver.username = kodi
xbmc.host = <IP ADDRESS GOES HERE>
webserver.port = <PORT FROM STEP 1 HERE>
download.threads = 15

Here is mine as an example:

webserver.username = kodi
xbmc.host = 192.168.1.3
webserver.port = 89
download.threads = 15

Save this file in the same directory as texturecache.py and call is "texturecache.cfg".  If using Notepad, make sure to put the name in quotes or you will get a '.txt. added to the end.

 

Note that the number of threads depends on the power of your system.  On my mid-power system, 15 works well, but YMMV.

 

9. Open a command prompt, cd to the directory with the script, and run 'texturecache.py c'

55636b80eb0a4_cmd.jpg

 

10. If all goes well, you are done!  Repeat steps 1, 2, 3, 8, 9  for each IP address of your Kodi boxes.

 

xnappo

Edited by xnappo
  • Like 6
Link to comment
Share on other sites

e123enitan

Kodi uses a local database to cache images to make browsing faster.

 

When you first sync Emby for Kodi, all the images are of course still on the server.

 

This causes two problems:

1. Browsing will be slow, particularly on low end devices

2. Some skins that make use of the local image database will not work correctly (showing black backdrops for instance)

 

To resolve this, you can run a tool called 'texturecache.py'.

 

This is a very powerful tool, and you can find the full documentation here:

http://forum.kodi.tv/showthread.php?tid=158373

 

However this post is intended JUST to get the images cached for Emby for Kodi.

 

Steps:

 

1. Go into Kodi and go to System->Sevices->Webserver and make sure that 'Allow control of Kodi via HTTP' is on.  Also make note of the Port - the default is 8080 - but I already had something on that port so changed it to 89.

556367ddb41f6_web.jpg

 

2. Go into Kodi and go to System->Sevices->Webserver and make sure that BOTH 'Allow programs on this system to control Kodi' AND 'Allow programs on other systems to control Kodi' are ON.

556368372e83d_remote.png

 

3. Exit Kodi and then start it again.

 

4. If you are a Linux/Mac user skip to Step 6.

 

5. Download and Install Python from here: https://www.python.org/ftp/python/2.7.10/python-2.7.10.msi

 

6. Download the texturecache.py script from here:https://raw.github.com/MilhouseVH/texturecache.py/master/texturecache.py

 

7. Put texturecache.py in a convenient path to get to from a command prompt.  On Windows I just stuck it in c:\Python26 - on Linux/Max your home directory is fine.

 

8. Open notepad or any text editor, and make a file with these contents:

webserver.username = kodi
xbmc.host = <IP ADDRESS GOES HERE>
webserver.port = <PORT FROM STEP 1 HERE>
download.threads = 15

Here is mine as an example:

webserver.username = kodi
xbmc.host = 192.168.1.3
webserver.port = 89
download.threads = 15

Save this file in the same directory as texturecache.py and call is "texturecache.cfg".  If using Notepad, make sure to put the name in quotes or you will get a '.txt. added to the end.

 

Note that the number of threads depends on the power of your system.  On my mid-power system, 15 works well, but YMMV.

 

9. Open a command prompt, cd to the directory with the script, and run 'texturecache.py c'

55636b80eb0a4_cmd.jpg

 

10. If all goes well, you are done!  Repeat steps 1, 2, 3, 8, 9  for each IP address of your Kodi boxes.

 

xnappo

You're awesomely incredulous; I love this dev's and forum they are quick to jump into supporting and resolving issues even when it seems unsurmountable. You make my households happy ALWAYS

 

I shall give this a go when I get home and report any concerns

Thanks :)

  • Like 1
Link to comment
Share on other sites

e123enitan

You're awesomely incredulous; I love this dev's and forum they are quick to jump into supporting and resolving issues even when it seems unsurmountable. You make my households happy ALWAYS

 

I shall give this a go when I get home and report any concerns

Thanks :)

6. Download the texturecache.py script from here:https://raw.github.c...texturecache.py

At step 6, I click on the link, then it openen below page, so at this point, I copied everything in this link and pasted into a Notepad and saved in Pythong folder, same for the command file, I saved in Python folder,  then proceeded to CMD @ command prompt I typed the command as you suggested, I kept getting and error, I could not locate Python pls let me know where I have gone wrong.

Thanks

 

 

#!/usr/bin/env python

# -*- coding: utf-8 -*-

################################################################################

#

#  Copyright © 2013 Neil MacLeod (texturecache@nmacleod.com)

#

#  This Program is free software; you can redistribute it and/or modify

#  it under the terms of the GNU General Public License as published by

#  the Free Software Foundation; either version 2, or (at your option)

#  any later version.

#

#  This Program is distributed in the hope that it will be useful,

#  but WITHOUT ANY WARRANTY; without even the implied warranty of

#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

#  GNU General Public License for more details.

#

#  You should have received a copy of the GNU General Public License

#  along with this program; if not, write to the Free Software

#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#

# Simple utility to query, validate, clean and refresh the XBMC texture cache.

#

# https://github.com/MilhouseVH/texturecache.py

#

# Usage:

#

#  See built-in help (run script without parameters), or the README file

#  on github for more details.

#

################################################################################

import os, sys, platform, re, datetime, time

import socket, base64, hashlib

import threading, random

import errno, codecs

import subprocess

import tempfile

 

5563dc88a763e_Texturecache.png

 

 

5563de03dbaf2_CMD.png

Link to comment
Share on other sites

Angelblue05

to navigate to it. you type:

cd c:\python27\
Edited by Angelblue05
  • Like 1
Link to comment
Share on other sites

badaas

I had to run as 'c:\Python27\python.exe texturecache.py c' as not integrated into shell for .py files, but apart from that all gravy!

Edited by badaas
Link to comment
Share on other sites

jasonmcroy

Thanks for this instruction! I tried it last night and finally have correct background images!

 

-Jason

  • Like 1
Link to comment
Share on other sites

e123enitan

Hi guys-below message was taken from CMD dos screen, 

As many times that I tried to connect with Kodi to texturecache, I get this message,

but when I try connect Kodi through web 192.168.1.157:8080, I was able to remotely control Kodi.

Is it something I have done wrong in my setup? thanks for your support. 

 

 

Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation.  All rights reserved.

C:\Users\tom>cd\

C:\>cd python27

C:\Python27>texturecache.py c
FATAL: The task you wish to perform requires that the web server is
       enabled and running on the XBMC system you wish to connect.

       A connection cannot be established to the following webserver:
       localhost:8080

       Check settings in properties file texturecache.cfg

C:\Python27>texturecache.py c
FATAL: The task you wish to perform requires that the web server is
       enabled and running on the XBMC system you wish to connect.

       A connection cannot be established to the following webserver:
       localhost:8080

       Check settings in properties file texturecache.cfg

C:\Python27>texturecache.py c
FATAL: The task you wish to perform requires that the web server is
       enabled and running on the XBMC system you wish to connect.

       A connection cannot be established to the following webserver:
       localhost:8080

       Check settings in properties file texturecache.cfg

C:\Python27>texturecache.py c
FATAL: The task you wish to perform requires that the web server is
       enabled and running on the XBMC system you wish to connect.

       A connection cannot be established to the following webserver:
       localhost:8080

       Check settings in properties file texturecache.cfg

C:\Python27>texturecache.py c
FATAL: The task you wish to perform requires that the web server is
       enabled and running on the XBMC system you wish to connect.

       A connection cannot be established to the following webserver:
       localhost:8080

       Check settings in properties file texturecache.cfg

C:\Python27>texturecache.py c
FATAL: The task you wish to perform requires that the web server is
       enabled and running on the XBMC system you wish to connect.

       A connection cannot be established to the following webserver:
       localhost:8080

       Check settings in properties file texturecache.cfg

C:\Python27>texturecache.py C
FATAL: The task you wish to perform requires that the web server is
       enabled and running on the XBMC system you wish to connect.

       A connection cannot be established to the following webserver:
       localhost:8080

       Check settings in properties file texturecache.cfg

C:\Python27>

Link to comment
Share on other sites

Angelblue05

Under settings > services > webserver > make sure the port is 8080. If it's not enabled, then make sure you put in the port number before allowing control via HTTP. :)

Link to comment
Share on other sites

e123enitan

Under settings > services > webserver > make sure the port is 8080. If it's not enabled, then make sure you put in the port number before allowing control via HTTP. :)

 

I did exactly as you mentioned, yet I am getting same error, it seems I am the only not making progress with the cache, defianately I must be doing something wrong, on a second thought, I am on OpenElec,  could there be a seperate process for this OS? 

 

Thanks

Link to comment
Share on other sites

xnappo

No - nothing special on OpenElec, but since you are clearly running from Windows in your error log, and you say your Kodi box is OpenElec, you must not have the IP address right in the config file because it says:

 

A connection cannot be established to the following webserver: localhost:8080

That 'localhost' needs to be the IP address of your OpenElec box.  If you made a config file like in step 8, then for some reason it is not finding it.  Double check that filename, and that the config file is in the same location as the script.

Edited by xnappo
  • Like 2
Link to comment
Share on other sites

e123enitan

 

No - nothing special on OpenElec, but since you are clearly running from Windows in your error log, and you say your Kodi box is OpenElec, you must not have the IP address right in the config file because it says:

 

A connection cannot be established to the following webserver: localhost:8080

That 'localhost' needs to be the IP address of your OpenElec box.  If you made a config file like in step 8, then for some reason it is not finding it.  Double check that filename, and that the config file is in the same location as the script.

 

Thanks I will duble check when I get home

Cheers!

Link to comment
Share on other sites

kolbasz

Keep in mind for the number of threads, it is super YMMV depending on the system.  My emby is running in docker and I get errors when running unless my threads is set to 1.

 

@@Angelblue05 also got errors, but he never confirmed if this fixed his issue too, but pay attention.  Too high of threads will make things error out.

  • Like 1
Link to comment
Share on other sites

marcelveldt

Latest beta of the Emby addon has the texture cache builtin, so no more need to do this manually...

 

@@xnappo maybe update or archive this thread ?

  • Like 1
Link to comment
Share on other sites

xnappo

The information in this post i no longer needed after version 1.0.04:

@marcelveldt's new features in the addon address both problems mentioned below

 

#1 is addressed by the new menu feature 'Cache all images to Kodi Texture cache'.  This takes a while, but only needs to be done once.

 

#2 is handled by the new settings option 'Auto add images to Kodi Texture cache' - which is on by default.

 

So.. No more need for texturecache.py!

  • Like 2
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...