cut/paste from README

Rob 2017-11-08 11:38:48 -06:00
parent 15a4cf1214
commit 2871804593

32
Scripting.md Normal file

@ -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
```