Use XBMC's plugin features from within a python script?
#1
Question 
Hi, I have written a script that on keypress fetches the Showtitle/Seasonnumber from the currently highlighted entry in the database - and then uses that information to do a search on a webpage for files related to that information, in the case of the first module of my plugin it is a search for .nzb files on a usenet page, that I then want to be able to pass to sabnzbd for file downloading.
Now what I would like to do - is present the information I have to the user like a plugin would, using xbmcplugin.addDirectoryItem(..). Is there a way to do that from within a script - like create a virtual directory and directly navigate to that, then populate it ?
Only way that came to my mind was: create a plugin in parallel to the script, write the infos the script gets into some file and then call the plugin with activate window and let it read that file and show the results. Doesn't sound like a great way. Is there a way I am overlooking here ? I don't really want to use WindowXML or something similar if I can avoid it, that sounds like alot of code for a simple listing of searchresults - and I have no experience with it.
Reply
#2
Hm ok, I really haven't found a satisfying way to do what I want. Here is the logic I have to use at the moment to try and achieve what I want:

- In Keymap.xml bind a key to RunPlugin(video/pluginname)
- Navigate in Library View to a tv show, press the key
- This calls my plugin - in Step 1, I evaluate sysv.arg[1] and check if it is "-1", if yes I know I have called the script from somewhere with my key. I now call a subroutine:

- Subroutine: parse InfoLabels for TvShowTitle, Season. Now I have to write those into a file - and call my plugin again, but this time instead of with RunPlugin with ActivateWindow. Since ActivateWindow doesn't allow me to pass parameters - I had to write a file that I can then again read in my plugin.

- Sys.argv is now something different than -1, so I now jump into a second subroutine, this one now reads the written file for the parameters, does the web parsing part and presents the infos in a list with the xbmcplugin features.

If somebody knows a better way, I would be interested to know Smile If not, maybe a feature request would be to give RunPlugin another parameter - allowing it to be used with IsFolder so I can directly pass my parameters to it - without that hackish filewriting subroutine ? Seems like what I want to do: A script combined with the features of plugins to create a simple gui-listing wasn't really something that was considered with the current API, or I don't know how to utilise it.
Reply
#3
you can pass args with activatewindow

notice the ?
PHP Code:
XBMC.ActivateWindow(windowid,plugin://video/Plugin Folder/?args) 
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#4
Haha, great Smile Well, at least I learned a bit about pythons os functions and the nice beautifulsoup library to read/write xml files in the process Smile
Reply

Logout Mark Read Team Forum Stats Members Help
Use XBMC's plugin features from within a python script?0