Access to objects/variables from previous run?
#1
Ok so the way Kodi works is that it runs my script for the first time.
I then list a bunch of things using xbmcplugin.addDirectoryItem and give each a different URL, so the next time Kodi runs my script I know exactly which item was selected.

So far so good, my question is this:
After the user selects one of the list items, and Kodi runs my script again, can I somehow access any of the objects/variables I created in the previous run?

(yes I am aware i can save them as files and load them up again but that's hardly efficient nor convenient)
Reply
#2
One way in a plugin is to create "hidden" values/variables in settings.xml and use xbmcgui.setSetting() and xbmcgui.getSetting() to store/retrieve values.

in settings.xml
<settings>
<setting id="var_1" type="text" visible="False" default=""/>
</settings>


in your plugin:
xbmcplugin.setSetting(int(sys.argv[1]), id='var_1', value='a new value')

v1 = xbmcplugin.getSetting(int(sys.argv[1]), 'var_1')
Reply
#3
Do note that I wrote I'm aware I can save them to files, one way or the other.
Also I need to load entire objects(aka class instances), and even lists of objects, so serialization will be needed. I doubt I can store all that data in settings.xml Wink

But still, I find it a bit unreasonable I even have to go through all this trouble. It seems extremely weird that when adding a ListItem you can only supply URLs and not simply a callback function that will run once the user clicks the item
Reply
#4
A plugin just manages the event and has no context from previous runs. There is nothing to callback to.
You can write a script, rather than a plugin, to manage events, etc that will remain resident.

The only rough equivalent to a callback in a plugin is a listitem url can call a plugin with parameters.
Reply

Logout Mark Read Team Forum Stats Members Help
Access to objects/variables from previous run?0