views:

48

answers:

2

Hi,

I am trying to make a WDTV Live plugin in linux, which plays a video from a web url.

I have a url that is parsed from html source code. The problem is that the url is playable in XBMC, but it can't be play in all the media players. I checked xbmc log, and it looks like that XBMC creates a session to the movie url. Below is log from XBMC log file.

INFO: XCURL::DllLibCurlGlobal::easy_aquire - Created session to http://121.125.77.146
DEBUG: CPlayerCoreFactory::GetPlayers(http://121.125.77.146/cgi-bin/sbview.cgi?systype=10000&subtype=4&id0=17678&id1=27635&id2=368507&id3=285792&nodeid=3071517&userno=0&userid=&level=1&part=0&ispay=0&mkey=2bd5454e93890a8ae2fe76948764a2d6&skey=5176153017445b5b79f897eec711996b&dummy=1279941981&title=%5bStar2Gether%5d%20%c0%cc%ba%a5%c6%ae%c0%fc_1%ba%ce&impurl=&TVINFO=10000,4,17678,27635,368507,285792,)

Is it possible to do what XBMC does in PHP? Thanks

A: 

Not sure how you are going to manipulate it but creating a session variable in php goes something like this:

session_start();

$_SESSION['var_name'] = 'session value/variable here';

Now you can access $_SESSION['var_name'] on any page provided that you put session_start() on a page where you are using that session variable.

Note that you can remove/unset a session like this:

session_start();
unset($_SESSION['var_name']);
session_destroy();
Sarfraz
@sAc: when you directly access the url, you get the 403 forbidden error message. Somehomw, XBMC creates a session on the server and then opens the url without a problem. I would like to know how XBMC creates a session on the url.
Moon
+1  A: 

Adding on sAc's answer, you'll also need to implement an authentication system if you only want a single media player to use it, kind of like what Netflix does. AFAIK, Netflix generates a key stored in your registry that identifies your computer and uses that key to access Netflix's servers. I assume XBMC has a similar implementation where it generates a key, stores it somewhere and uses that key as the session ID.

From the URL you've given, there are two parameters where I saw keys similar to the keys I explained above: "mkey=2bd5454e93890a8ae2fe76948764a2d6&skey=5176153017445b5b79f897eec711996b" These keys are passed through the querystring (everything the ? in the URL) that could possibly identify your XBMC.

In order to reproduce this, you really won't need PHP sessions eg:

session_start();
$_SESSION['session_key'] = $_REQUEST['session_key']; // Use either $_GET or $_POST in production
if($_SESSION['session_key'] == "the_super_secret_key") { /* play video */ }

This is a very crude example, but you can strip the sessions altogether because you're using API calls. the_super_secret_key can also be retrieved from a database to match with the session key sent.

Gio Borje
@Gio Borje, actually I passed those mkey and skey to XBMC. XBMC did rest of things. I really wonder what XBMC does exactly. I googled DllLibCurlGlobal class, but could not find any useful information.
Moon
Well, that blows my theory. I've never actually used XBMC before, but the URL looks like an API call: http://en.wikipedia.org/wiki/Application_programming_interface
Gio Borje
@Gio Borje// indeed, the url looks like an API. I really wonder how DllLibCurlGlobal class makes a session on the url server. I will research on it. Thank you for your input!
Moon