Sign up here and you can log into the forum!

UMSP "Bookmarks" / Downloading?

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

Re: UMSP "Bookmarks" / Downloading?   

Postby shunte » Tue May 31, 2011 3:27 pm

here is test rig example specific to rev3

theres a bit more code here than you need as its geared to my development workflow, example call and further explanation after the code

Code: Select all
<?php

function getMicroTime()
{
   list($usec, $sec) = explode(' ',microtime());
   return ((float)$usec + (float)$sec);
}

function testCleanSyntax($codeFiles)
{
   $ret = true;
   foreach($codeFiles as $codeFile)
   {
      if(file_exists($codeFile))
      {
         $cmd = "php-cgi -l $codeFile"; // use lint to check clean syntax
         $exec = shell_exec($cmd);
         if(strpos($exec,'<b>Parse error</b>')!==false)
         {
            echo "Synatx error in $codeFile\n$exec\n";
            $ret = false;
            break;
         }
         else
            echo "Ok :: $exec\n";
      }
   }
   return $ret;
}

$test = 'revision3';
$cmdtest = __DIR__.'/'.$test.'/'.$test.'.php';

# test clean syntax on usual suspects, won't even move files unless clean!!!
if(testCleanSyntax (
array (
$cmdtest,
str_replace($test.'.php','info.php',$cmdtest),
str_replace($test.'.php','config.php',$cmdtest),
str_replace('.php','-helper.php',$cmdtest),
str_replace('.php','-proxy.php',$cmdtest),
str_replace('.php','_wec.php',$cmdtest),
)))
{

# make sure we have the code we wish to evaluate
#shell_exec('mkdir /tmp/umsp-plugins/'.$test);
#shell_exec('cp -fR '.__DIR__.'/'.$test.'/* /tmp/umsp-plugins/'.$test.'/');

# path to the plugin to "debug"
$cmdtest = '/tmp/umsp-plugins/'.$test.'/'.$test.'.php';

include_once($cmdtest);
echo "$cmdtest\n";
#start
print "TEST BEGINS>>>\n";
$r= array();
for($z=1;$z<=3;$z++)
{
$i=substr($r[0]['id'],strpos($r[0]['id'],'?')+1,strlen($r[0]['id']));
print "IN TEST>>>\n$i\n";
$intime = getMicroTime();
$r=_pluginMain($i);
$time = getMicroTime() - $intime;
print_r($r);
print "\n$i\nTest [$test] Menu Drilldown [$z] ".round($time,2)." seconds.\n<<<IN TEST\n";
}
print "<<<<TEST ENDS\n";

print_r(_pluginSearch('and dc:title contains "panasonic plasma"'));

}

?>


example call
Code: Select all
sync && php5-cgi r3test.php | cat > grabem.sh


what my test script does is traverse a menu structure, it takes the first menu and drills down until it gets no more UMSP entries, depending on the menu depth it may start over again.

Given the first menu is Today On Rev3 it'll pull a number of shows

what it dumps are the actual items that form menus and playable content under UMSP

Its not exactly what you're looking for but it may help your thought process along

once you have the .sh spooled edit it into a simple script, grab all the [res] lines and convert them to wget

Code: Select all
    [0] => Array
        (
            [id] => umsp://plugins/revision3/revision3?url=http%3A%2F%2Fvideos.revision3.com%2Frevision3%2Fweb%2Fepicmealtime%2F0033%2Fepicmealtime--0033--84eggsandwich--large.h264.mp4
            [dc:title] => Epic Meal Time - 84 Egg Sandwich - Epic Meal Time
            [res] => http://videos.revision3.com/revision3/web/epicmealtime/0033/epicmealtime--0033--84eggsandwich--large.h264.mp4
            [upnp:artist] => feedback@revision3.com (Revision3)
            [upnp:genre] => Comedy
            [upnp:album] => 84 Egg Sandwich - Epic Meal Time
            [upnp:album_art] => http://videos.revision3.com/revision3/images/shows/epicmealtime/0033/epicmealtime--0033--84eggsandwich--mini.thumb.jpg
            [size] => 30527212
            [dc:date] => Tue, 31 May 2011 13:00:00 GMT
            [protocolInfo] => http-get:*:video/mp4:*
            [upnp:class] => object.item.videoItem
        )

    [1] => Array
        (
            [id] => umsp://plugins/revision3/revision3?url=http%3A%2F%2Fvideos.revision3.com%2Frevision3%2Fweb%2Ffilmstate%2F0013%2Ffilmstate--0013--20110531--large.h264.mp4
            [dc:title] => Film State - First look at Bane, Muppets & Sharks in 3D = Bikinis? - Film State
            [res] => http://videos.revision3.com/revision3/web/filmstate/0013/filmstate--0013--20110531--large.h264.mp4
            [upnp:artist] => feedback@revision3.com (Revision3)
            [upnp:genre] => TV & Film
            [upnp:album] => First look at Bane, Muppets & Sharks in 3D = Bikinis? - Film State
            [upnp:album_art] => http://videos.revision3.com/revision3/images/shows/filmstate/0013/filmstate--0013--20110531--mini.thumb.jpg
            [size] => 163228081
            [dc:date] => Tue, 31 May 2011 21:00:00 GMT
            [protocolInfo] => http-get:*:video/mp4:*
            [upnp:class] => object.item.videoItem
        )

    [2] => Array
        (
            [id] => umsp://plugins/revision3/revision3?url=http%3A%2F%2Fvideos.revision3.com%2Frevision3%2Fweb%2Ftomstop5%2F0050%2Ftomstop5--0050--mostwantedjune--large.h264.mp4
            [dc:title] => Tom&apos;s Top 5 - Top 5 Most Wanted Gadgets for June 2011 - Tom's Top 5
            [res] => http://videos.revision3.com/revision3/web/tomstop5/0050/tomstop5--0050--mostwantedjune--large.h264.mp4


just pull out the res lines and convert to wget statements, e.g.
Code: Select all
#!/usr/bin/bash
wget http://videos.revision3.com/revision3/web/epicmealtime/0033/epicmealtime--0033--84eggsandwich--large.h264.mp4
wget http://videos.revision3.com/revision3/web/filmstate/0013/filmstate--0013--20110531--large.h264.mp4
wget http://videos.revision3.com/revision3/web/tomstop5/0050/tomstop5--0050--mostwantedjune--large.h264.mp4


make executable and run it
Code: Select all
chmod 666 grabem.sh
. grabem.sh
--2011-05-31 19:24:58--  http://videos.revision3.com/revision3/web/epicmealtime/0033/epicmealtime--0033--84eggsandwich--large.h264.mp4
Resolving videos.revision3.com... 208.67.238.238
Connecting to videos.revision3.com|208.67.238.238|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30527212 (29M) [video/mp4]
Saving to: `epicmealtime--0033--84eggsandwich--large.h264.mp4'

2% [==>                                                                                                                                                  ] 771,752      141K/s  eta 3m 47s 

or alternatively go download what you want directly from rev3 - either way have fun :)
If you like the work I do please feel free to make a donation to the Red Cross
User avatar
shunte
Developer
 
Posts: 420
Joined: Sun Sep 19, 2010 1:43 am
Location: Cambridge, MA U. S. and A.

Re: UMSP "Bookmarks" / Downloading?   

Postby mad_ady » Wed Jun 08, 2011 11:18 pm

voiper99: If you haven't started to work I just realized there's an easy way to save the content that you view.
If you navigate to http://your-wdtv-ip/umps/umsp-test.php you can navigate through your plugins in a browser. If you click on some content you will be prompted to play/save that content.

I wonder why I didn't think of this sooner...
User avatar
mad_ady
Developer
 
Posts: 4573
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: UMSP "Bookmarks" / Downloading?   

Postby voiper99 » Thu Jun 09, 2011 1:07 am

Thanks ady! hehe, I don't know why I didn't think of it either seeing as though I looked in to umsp-test.php during my workings.

I haven't given coding a try yet but have enjoyed my experimenting so far. My goal is to try my hand at creating a new UMSP stream though my first road block is that you need to log in in order to view the content. However, I have seen other UMSP plugins which require that you enter your login credentials through the Webend, so hopefully I'll be able to use those as a guide.
voiper99
Donor
 
Posts: 51
Joined: Sun Jul 18, 2010 2:33 pm

Re: UMSP "Bookmarks" / Downloading?   

Postby mad_ady » Thu Jun 09, 2011 1:56 am

Login varies from site to site (some sites provide APIs to allow scripts to easily log in, others require you to work around the login screen).
What is the site you are trying to create a plugin for (it's useful to know so that other developers don't duplicate your work)?
User avatar
mad_ady
Developer
 
Posts: 4573
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: UMSP "Bookmarks" / Downloading?   

Postby voiper99 » Thu Jun 09, 2011 2:03 am

Thanks for the info. I was wanting to write a plugin for SkyDrive (Hotmail's free 25gb cloud storage).

I was thinking WebDAV (see http://www.mikeplate.com/2010/01/17/how-to-connect-to-skydrive-with-webdav/ ) could be the way to go.

I thought it would be great for users who put their photos and videos in the cloud, however, once I read "API" and "work around" in your post, I fear that I may be in over my head :(
voiper99
Donor
 
Posts: 51
Joined: Sun Jul 18, 2010 2:33 pm

Re: UMSP "Bookmarks" / Downloading?   

Postby mad_ady » Thu Jun 09, 2011 3:01 am

An API is always preferred over page scraping. It ensures that you have a reliable set of actions you need to do to access something. Page scraping often breaks when the provider changes simple things in their HTML layout.

I haven't worked with webdav, but you might need extra programs/php modules to enable that functionality. For cloud content access I would look into a way to "mount" the cloud storage on the wdtv and then access the files via the regular file browser. All the complexity of the mounting process would be handled by the mounting tools (e.g. fuse).

I know there was a way to mount your google account (docs) as a directory. For this you would need fuse and a program to handle the mounting. I'm not sure if it works, but in theory, it should. You could then pack everything as an app.bin and it would work transparently to the end user.

http://ubuntuforums.org/showthread.php?t=894930 - here it says to give SMEStorage a try.
SMEStorage has an API that can expose everything as FTP which could be easily mounted on the wdtv: http://www.smestorage.com/?p=static&page=CloudFTP
There's a catch, though - access to the API is not free :(
User avatar
mad_ady
Developer
 
Posts: 4573
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: UMSP "Bookmarks" / Downloading?   

Postby voiper99 » Thu Jun 09, 2011 3:51 am

Thanks for taking the time to write such an informative reply :)

In regards to you mentioning app.bins, great, now you've gone and gotten me interested in those too :P

This is a bit off topic, but I have been looking at Bind9 and wouldn't mind using it as my first app.bin project.

I have seen http://wiki.wdlxtv.com/Creating_an_app_bin and http://sourceforge.net/apps/trac/wdtvtools/wiki/Tutorials/CreateApplicationImage which are a great starting point, but don't know how I would go about putting Bind9 in to an app.bin. Are you able to give me some quick pointers?

Also, in regards to the cramfs vs ext3, which one do you recommend? I'm leaning towards cramfs as it looks easier to use. However, I am using an ext3 firmware on a USB stick so don't know if that makes a difference?

Thanks :)
voiper99
Donor
 
Posts: 51
Joined: Sun Jul 18, 2010 2:33 pm

Re: UMSP "Bookmarks" / Downloading?   

Postby mad_ady » Thu Jun 09, 2011 4:11 am

First of all, you will need to get all the necessary bits of your application under a single directory structure (which will be packaged as an app.bin). This means, you need binary files, libraries (or you can compile them statically) and other files that the program might need and you need to place them under a single directory (within subdirectories).
The best way to understand this is to get an existing app.bin (e.g. mc.app.bin or iftop.app.bin) and place it on the wdtv. Reboot the wdtv and then telnet in and you should see the application mounted automatically under /apps/application_name.

Having a directory structure ready you can build your app.bin:
1. cramfs - is preffered if there is no need to change the files that are bundled with the app. The thing is - you can only build compatible app bins for the wdtv with a custom mkcramfs-16k utility that you can find here: http://forum.wdlxtv.com/viewtopic.php?f=43&t=537&start=0
The syntax is simple -
Code: Select all
mkcramfs-16k folder_with_the_files/ my.app.bin

2. ext3 - can allow free space inside the image (but makes the image larger), and also has a risk of corrupting the filesystem if it is not cleanly unmounted a lot of times.

When you are done testing and want to distribute the app.bin, make sure to add an application.xml to it so that it is compatible with the new application manager that is coming in 0.5: http://forum.wdlxtv.com/viewtopic.php?f=51&t=4441
User avatar
mad_ady
Developer
 
Posts: 4573
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: UMSP "Bookmarks" / Downloading?   

Postby voiper99 » Thu Jun 09, 2011 4:39 am

mad_ady wrote:First of all, you will need to get all the necessary bits of your application under a single directory structure (which will be packaged as an app.bin). This means, you need binary files, libraries (or you can compile them statically) and other files that the program might need and you need to place them under a single directory (within subdirectories).


Would I be correct in saying you are referring to dependencies?

What I'm wondering is, just say you've got an app that needs to use Apache, how does that work? Would you need to manually edit the already installed Apache software on the WDTV?

By the way, I tried to view the link in your post - http://forum.wdlxtv.com/viewtopic.php?f=51&t=4441 - but it says I do not have permission :( I assume it may only be available for Devs.
voiper99
Donor
 
Posts: 51
Joined: Sun Jul 18, 2010 2:33 pm

Re: UMSP "Bookmarks" / Downloading?   

Postby mad_ady » Thu Jun 09, 2011 5:10 am

Would I be correct in saying you are referring to dependencies?


Yes, however - if your app bin depends/is integrated with a different app bin you can have custom scripts bundled with your app bin to do the necessary configurations on the other side (e.g. - enable a virtual host under apache (copy the config file) and restart apache). The scripts are run when the app bin is started.

You can't access that link because it's a discussion in the Beta Testing area - which is reserved for donors (10$) and features some previews for new features. Information about the xml file you need to distribute with the app bin will be documented on the wiki as soon as the format of the xml is stable.
User avatar
mad_ady
Developer
 
Posts: 4573
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

PreviousNext

Return to UMSP Media Server

Who is online

Users browsing this forum: No registered users and 1 guest

cron