2023-08-14, 02:34
Hi,
I have an addon, named: service.subtitles.subs (example name)
with the following module:
service.subtitles.subs/resources/modules/clean_cache_functions.py
I'm trying to call this module with action = "clean_folders" parameter, from addon's setting. Using RunScript().
settings.xml:
I'm stuck on this error:
The code can't identify addon ID, for addon information (name, icon, etc..)
Thanks for help
I have an addon, named: service.subtitles.subs (example name)
with the following module:
service.subtitles.subs/resources/modules/clean_cache_functions.py
Python:# Imports
import xbmcgui,xbmcvfs,xbmcaddon
import os,shutil,sys
# Addon parameters
MyAddonName = xbmcaddon.Addon().getAddonInfo('name')
iconx=xbmcaddon.Addon().getAddonInfo('icon')
# Cache Directories
xbmc_tranlate_path = xbmcvfs.translatePath
user_dataDir = xbmc_tranlate_path(xbmcaddon.Addon().getAddonInfo("profile"))
CachedSubFolder = xbmc_tranlate_path(os.path.join(user_dataDir, 'cache'))
TransFolder = xbmc_tranlate_path(os.path.join(user_dataDir, 'trans'))
# Notify function
def notify(msg_id, times=500, icon=iconx,sound=False):
xbmcgui.Dialog().notification(MyAddonName, msg_id, icon, int(times), sound)
# Get command line arguments
args = sys.argv
action = None
# Check if the script is called with arguments
if len(args) > 1:
action = args[1]
if action == "clean_folders":
# some code
I'm trying to call this module with action = "clean_folders" parameter, from addon's setting. Using RunScript().
settings.xml:
XML:<setting label="Clean Folders" type="action" action="RunScript(special://home/addons/service.subtitles.subs/resources/modules/clean_cache_functions.py, clean_folders)" />
I'm stuck on this error:
Log:error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'RuntimeError'>
Error Contents: No valid addon id could be obtained. None was passed and the script wasn't executed in a normal Kodi manner.
Traceback (most recent call last):
File "C:\Users\my_user\AppData\Roaming\Kodi\addons\service.subtitles.All_Subs\resources\modules\clean_cache_functions.py", line 6, in <module>
MyAddonName = xbmcaddon.Addon().getAddonInfo('name')
RuntimeError: No valid addon id could be obtained. None was passed and the script wasn't executed in a normal Kodi manner.
-->End of Python script error report<--
The code can't identify addon ID, for addon information (name, icon, etc..)
Thanks for help