Background Processes
#1
I'm in the process of exploring the new plugin features, and I'm particularly interested in using a video plugin to browse feeds from a protected/registered users only site.

I've been able to successfully get authentication to occur and to setup regexes to extract the appropriate mms urls from the HTML.

I'm at a point now, however, where there are several possible options, and I wanted to see which was the XBMC ideal way.

Currently, for users of the site, a JavaScript timer gets setup after a successful login that refreshes a generic page every 30 seconds, used as a keep-alive to keep the session currently alive. This occurs even while playing videos, as the site is based around frames, and the JS is just updating one (small) frame.

Since I'm using the Video Plugin, I don't want to use a Sleep timer/while loop, since that will keep all these scripts alive. I want the script to continue to be a "one-off" - that is, that the video plugin can request the listing/folder/file and have the script terminate successfully when it's returned.

One way I thought of implementing this was calling a builtin function to call RunScript, and actually running a secondary helper script. This script, in pseudo code, would look like

Code:
if (os.path.exists(pidFile)):
      return
   else:
      create pidFile
      loop = True
      while(loop):
         if (os.path.exists(killFile)):
           loop = False
         else:
           request URL
      remove killFile
      remove pidFile

This would (hopefully) ensure only one copy of this script gets run, and that it continues to run in the background. It never instantiates any GUI, and to kill it, one only needs touch the killFile and it'll get terminated.

This script would need to continue running during video playback, as that is part of the session keep alive problem.

A second method would be to create a client/server model, where a script runs as a server, and the plugin runs as a client. The server is responsible for actually obtaining all of the data, and will also use multiple threads. One thread will listen to requests from client(s), while, once the system is flagged as 'logged in', another thread will continue to request the keep-alive page in the background.

This latter method seems much, much more complex (and I am a new Python programmer, although long-time programmer in C++/PHP/JavaScript/C#/VBScript/VB.NET/etc), but it has the gut-feeling that it is more likely to work than the first method I described.

I'd like to get feedback from those who have been actively developing for a while, who know the limitations and features of the python support in XBMC, and of the recent plugin features, and who can advise me the best way to go about this.
Reply

Logout Mark Read Team Forum Stats Members Help
Background Processes0