Skip to content
Rob edited this page Nov 8, 2017 · 4 revisions

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:

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:

#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
Clone this wiki locally