From 28718045936315c793d33550a28e5a9e45a707ce Mon Sep 17 00:00:00 2001 From: Rob <1572423+robweber@users.noreply.github.com> Date: Wed, 8 Nov 2017 11:38:48 -0600 Subject: [PATCH] cut/paste from README --- Scripting.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Scripting.md diff --git a/Scripting.md b/Scripting.md new file mode 100644 index 0000000..7c2ff0f --- /dev/null +++ b/Scripting.md @@ -0,0 +1,32 @@ +## Scripting A Backup + +If you wish to script this addon using an outside scheduler or script it can be given parameters via the Kodi.RunScript() or JsonRPC.Addons.ExecuteAddon() methods. Parameters given are either "backup" or "restore" to launch the correct program mode. If mode is "restore", an additional "archive" parameter can be given to set the restore point to be used instead of prompting via the GUI. An example would be: + +Python code: +```python +RunScript(script.Kodibackup,mode=backup) +``` + +JSON Request: +``` +{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon","params":{"addonid":"script.Kodibackup","params":{"mode":"restore","archive":"000000000000"}}, "id": 1 } +``` + +There is also a windows parameter that can be used to check if Kodi Backup is running within a skin or from another program. It is attached to the home window, an example of using it would be the following: + +```python +#kick off the Kodi backup +Kodi.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon","params":{"addonid":"script.Kodibackup","params":{"mode":"backup"}}, "id": 1 }') + +#sleep for a few seconds to give it time to kick off +Kodi.sleep(10000) + +window = Kodigui.Window(10000) + +while (window.getProperty('script.Kodibackup.running') == 'true'): + #do something here, probably just sleep for a few seconds + Kodi.sleep(5000) + +#backup is now done, continue with script +``` +