Sign up here and you can log into the forum!

Help writing UMSP Plugin for Presto streaming service

Discussion, features, plugins--everything about zoster's UMSP UPnP Media Server software

Re: Help writing UMSP Plugin for Presto streaming service   

Postby recliq » Tue Apr 07, 2015 4:38 am

I'm afraid using the extracted cookie may only work for a limited time period, because that's what session cookies are intended for.
So you still need to write some code to obtain a session cookie before you get access to the stream itself.
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: Help writing UMSP Plugin for Presto streaming service   

Postby mad_ady » Tue Apr 07, 2015 5:54 am

Ideally you'd need to do what recliq suggests. But for small tests, local tests you could do with a static cookie.

What you need now is to write a static umsp proxy. Again, more gory details you can find in the UMSP development guide on the wiki, but, to keep it simple you need this:

1. Create a php file called presto-proxy.php and place it under /tmp/umsp-plugins/presto-proxy.php (note - it will be lost on reboot, so keep a copy safe someplace else)
2. Modify your res entry to look like this:
Code: Select all
'res' => ''.base64_encode("$real_video_URL").'&cookie='.$cookie,

You can have $real_video_url and $cookie set as variables before the $myMediaItems string in the script. Point them to the actual content you want/is correct.

Now, the challenging part comes - where you write the proxy code. It behaves like the real server and should return back the content of the video you request. Try something like this (highly untested!):
Code: Select all
include_once( $_SERVER['DOCUMENT_ROOT'] . '/umsp/funcs-log.php' );
// set the logging level, one of L_ALL, L_DEBUG, L_INFO, L_WARNING, L_ERROR
global $logLevel;
$logLevel = L_WARNING;
global $logIdent;
$logIdent = 'presto-proxy';

_logInfo("Starting execution. \$_SERVER is:".serialize($_SERVER));
$real_url = base64_decode($_GET['url']);
$cookie = $_GET['cookie'];

_logInfo("Getting content for video ".$real_url." with cookie $cookie");

$opts = array(
                'header'=>"Accept-language: en\r\n" .
                                  "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13 -- wdlxtv\r\n" .
                                  "Content-Type: application/x-www-form-urlencoded\r\n".
                                  "Cookie: $cookie;\r\n",
$context = stream_context_create($opts);
$socket = fopen("$real_url","r", false, $context);
header("Content-Type: video/mp4");

Again, I wrote the code above directly in the browser - so expect erorrs (keep an eye on /var/log/php5/error_log). The code should get an url and a cookie and make a request to that URL with that cookie and send back to the media player Content-Type: video/mp4, and the actual data. It's not perfect (you'd ideally need to send some extra headers as well that you need to extract from the server's response, but it should get the job done.

It would be easier for you to learn things at your own pace and not try to undestand too much what I did, but give it a try or come back with other questions...

Good luck!

P.S. In case of problems it would help to provide real URLs, real cookies, real headers (from firebug) to see what's missing.
User avatar
Posts: 4570
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania


Return to UMSP Media Server

Who is online

Users browsing this forum: No registered users and 1 guest