Hey all,
Does anyone have any suggestion for running TCMU from a Kodi addon in windows? I ask because in windows I mainly use Kodi as a launcher for games and emulators so it is not running all the time, plus there is no ssh so the only way to run it is by accessing the desktop. I've made a addon to launch a script which runs TCMU (so its easy to run while a big game downloads in Steam and I'm watching something) and the script works well outside of Kodi, though when launching the addon via kodi I get the error: 'fatal python error:py_initialize: unable to load the filesystem codec'.
Screenshot. I think its trying to use Kodi's built in python - Ive tried setting the working directory and the PATH variable to the python install directory in the AHK script, to no avail, I always get the same error.
The addons default.py (it's a bit rough, I've reused other bits and pieces):
Code:
import xbmc, os, xbmcaddon, subprocess
addon = xbmcaddon.Addon()
script = '"c:\Program Files\AutoHotkey\AutoHotkeyU64.exe" "c:\Emulation\scripts\Ahk\kodi-cleanup.ahk"'
print(script)
subprocess.Popen(script, shell=True, close_fds=True)
The AHK script:
Code:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
SetWorkingDir, c:\Python33
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"GUI.ShowNotification\"`,\"params\":{\"title\":\"Texture Cache Maintenance\"`,\"message\":\"Starting\"`,\"image\":\"c:/emulation/artwork/cache-maintenance.png\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
WinWait, Kodi ahk_class Kodi
Sleep, 5000
Run, %comspec% /c PYTHONPATH="C:\python33\DLLs;C:\python33\Lib;C:\python33\Lib\site-packages"
RunWait, c:\Python33\python.exe c:\Users\xbmc\AppData\Roaming\Kodi\texturecache.py u, c:\Users\xbmc\AppData\Roaming\Kodi ;, Hide
RunWait, %comspec% /c c:\Python33\python.exe c:\Users\xbmc\AppData\Roaming\Kodi\texturecache.py u, c:\Python33 ;, Hide
RunWait, %comspec% /c c:\Python33\python.exe c:\Users\xbmc\AppData\Roaming\Kodi\texturecache.py c, c:\Python33 ;, Hide
RunWait, %comspec% /c c:\Python33\python.exe c:\Users\xbmc\AppData\Roaming\Kodi\texturecache.py P, c:\Python33 ;, Hide
RunWait, %comspec% /c c:\Python33\python.exe c:\Users\xbmc\AppData\Roaming\Kodi\texturecache.py R, c:\Python33; , Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"GUI.ShowNotification\"`,\"params\":{\"title\":\"Texture Cache Maintenance\"`,\"message\":\"Completed\"`,\"image\":\"c:/emulation/artwork/cache-maintenance.png\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
I'm not adverse to doing everything in python, its just I'm not overly familiar with it and I've just reused bits of other stuff I already have for Kodi.