Kodi Community Forum

Full Version: Load video URL on demand?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am looking for a way to load the URLs of DirectoryItems in my addon when they are selected, rather than when loading the directory.

My addon currently loads the URLs of 20 livestreams in succession when the addon is loaded (when the addon name is selected in the ‘Video Add-ons’ menu), which takes a considerable length of time. I would like for this not to happen, by fetching the URL of each livestream only when it is accessed.

Is there any way I can do this, aside from putting each DirectoryItem into its own directory?

My code currently looks like this:
Code:
def addStream(channelID, channelName):
    #Fetch the stream URL from the server.
    ...
    
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

addStream(...)
addStream(...)
addStream(...)
addStream(...)
addStream(...)
addStream(...)
addStream(...)
addStream(...)
addStream(...)
...

xbmcplugin.endOfDirectory(addon_handle)
that's how 99% of plugins work. just see something and monkey it.

basically; you return a plugin:// url and mark it as playable. then when the item is clicked in the ui, a callback to your plugin is done, in which you return the real url using setResolvedUrl().

see e.g. here http://paste.ubuntu.com/9567731/
(2014-12-19, 10:30)ironic_monkey Wrote: [ -> ]that's how 99% of plugins work. just see something and monkey it.

basically; you return a plugin:// url and mark it as playable. then when the item is clicked in the ui, a callback to your plugin is done, in which you return the real url using setResolvedUrl().

see e.g. here http://paste.ubuntu.com/9567731/

Thanks! I replaced the url in addDirectoryItem with a plugin:// URI handled by the addon, and it works great!