diff --git a/addon.xml b/addon.xml index e81c832..f2106dd 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/lib/iapc/service.py b/lib/iapc/service.py index 6bdf093..22f3828 100644 --- a/lib/iapc/service.py +++ b/lib/iapc/service.py @@ -10,7 +10,7 @@ import xbmc -from .tools import Logger, getAddonId, executeJSONRPC +from .tools import executeJSONRPC, getAddonId, Logger # ------------------------------------------------------------------------------ diff --git a/lib/iapc/tools/addon.py b/lib/iapc/tools/addon.py index fd579fe..7f31105 100644 --- a/lib/iapc/tools/addon.py +++ b/lib/iapc/tools/addon.py @@ -5,7 +5,8 @@ "getAddonId", "getAddonName", "getAddonVersion", "getAddonPath", "getAddonIcon", "getAddonProfile", "getLanguage", "localizedString", "maybeLocalize", - "getMediaPath", "getMedia", "makeProfile", + "getMediaPath", "getMedia", + "pathExists", "profileExists", "makeProfile", "openSettings", "getSetting", "setSetting", "Logger" ] @@ -55,19 +56,28 @@ def maybeLocalize(value): return value -__media_path__ = join(getAddonPath(), "resources", "media") +__media_path__ = join("resources", "media") def getMediaPath(*args): - return join(__media_path__, *args) + return join(getAddonPath(), __media_path__, *args) def getMedia(name, ext="png"): return getMediaPath(f"{name}.{ext}") +def pathExists(path): + return xbmcvfs.exists(path) + + +def profileExists(): + return pathExists(getAddonProfile()) + + def makeProfile(): - if not xbmcvfs.exists(profile := getAddonProfile()): - xbmcvfs.mkdirs(profile) + if not pathExists(profile := getAddonProfile()): + return xbmcvfs.mkdirs(profile) + return False # settings --------------------------------------------------------------------- diff --git a/lib/iapc/tools/execute.py b/lib/iapc/tools/execute.py index abfda9b..8edeb37 100644 --- a/lib/iapc/tools/execute.py +++ b/lib/iapc/tools/execute.py @@ -3,7 +3,8 @@ __all__ = [ "executeBuiltin", "executeJSONRPC", - "containerRefresh", "containerUpdate", "playMedia", "addFavourite" + "containerRefresh", "containerUpdate", "playMedia", "runScript", + "addFavourite" ] @@ -58,7 +59,10 @@ def containerUpdate(*args): def playMedia(*args): executeBuiltin("PlayMedia", *args) +# runScript +def runScript(*args): + executeBuiltin("RunScript", *args) + # addFavourite def addFavourite(title, type, **kwargs): executeJSONRPC("Favourites.AddFavourite", title=title, type=type, **kwargs) -