Add Python Function as Directory Item in-place of URL
#1
I am currently using the requests and re modules to scrape podcasts from http://podbay.fm/show/1089022756. The source website links to pages that include a source mp3 for each podcast, therefore I would need an individual request for each podcast in the list. It takes about 45 seconds to fetch only the 6 most recent podcasts. Can I add directory items that executes a python function when the user selects the item? I have found xbmc.executebuiltin('XBMC.RunScript(...)') but no way to link it to a directory item inplace of a URL. Thank you.
Reply
#2
yes, look into any plugin being implemented correctly for examples - cluestick: setResolvedUrl.
basics:

you return a plugin:// url pointing to your plugin, make it a *file* and set the 'isPlayable' property. in the url you encode the info to know which podcast to resolve
when users click the item in the list, a callback to your plugin is performed. you then return the actual playback url using setResolvedUrl.
Reply
#3
(2017-12-02, 01:11)spiff Wrote: yes, look into any plugin being implemented correctly for examples - cluestick: setResolvedUrl.
basics:

you return a plugin:// url pointing to your plugin, make it a *file* and set the 'isPlayable' property. in the url you encode the info to know which podcast to resolve
when users click the item in the list, a callback to your plugin is performed. you then return the actual playback url using setResolvedUrl.
This works, you need to set the url = 'plugin://plugin.audio.example/?dosomething=foobar'. In the beginning of the main you can check for to see if a query is being passed into the plugin with 
Quote:if str(sys.argv[2]):
#Request and Scrape for link
xbmc.Player().play( link)  
Reply
#4
Don't use player, you return the url using setResolvedUrl or stuff like resume and settings won't work properly.
Reply

Logout Mark Read Team Forum Stats Members Help
Add Python Function as Directory Item in-place of URL0