Sign up here and you can log into the forum!

Plugin: StageVu (free streaming movies) - v 0.4

UMSP Plugin Depot, the place for sharing plugins & info about them. No requests, just plugins/code.

Plugin: StageVu (free streaming movies) - v 0.4   

Postby monkmad » Fri Feb 25, 2011 10:35 am

NOTE: The plugin is available via the webend now. No need to use the files below.


UPDATE v 0.4 2011-02-28

There was a url encoding issue in v 0.3 which caused problems. It is fixed now.

Click this Download Link to get it. The instructions remain the same as v 0.3

UPDATE v 0.3 2011-02-27
With lightening speed, here is the third update in close to 24 hrs :mrgreen:

  • Canned search enabled - Use webend to specify the full path to the search criteria file
  • Search criteria file is very simple; just put one search term per line, e.g.
    Code: Select all
    Wall Street
    Toy Story
    Fringe
  • Using the plugin is now easier than ever:
    1. Just download the file and upload/copy it to the /conf folder on your WDTV
    2. Restart the WDTV (or restart just the UMSP server)
    3. Go to the webend and enable the plugin
    4. Enjoy 8-)

UPDATE v 0.2 2011-02-27

Version 0.2 Click here to download

(Extract the stagevu folder and copy it to the umsp/plugins folder. Enable from webend and Enjoy 8-) )

Features:
  • WEC configuration (thanks nicandmih)
  • Sort Category items by Rating, Views or Relevance
  • Sort Search results by Rating, Views or Relevance (configure through webend)
  • Specify number of items to fetch in category views AND search results (7,14,21 or 28) - keep in mind that it takes longer to fetch more items (duh)

----------------------------------------

Here is a zip file for those who have non-writable firmwares (flashed versions). Just download the zip file and read the README.txt inside


----------------------------------------
Hi all,

As mentioned elsewhere on the forum, I tried to make a plugin for the website StageVu.com , by using Yahoo Pipes at first. However, that didn't work so well. So, finally I got around to rewriting the complete plugin in PHP. The code is below; save it as "stagevu.php" in the /var/www/umsp/plugins directory and add the appropriate entries to /conf/umsp.php.

Feedback is appreciated. ;)

Some features:
  • Supports different StageVu categories, such as Comedy, Animation, Films & Movies etc.
  • Search enabled (Hint: Once inside the plugin, click the "Search" button and try searching for something e.g. toy story :mrgreen: )
  • MediaNavigation works - skip to any point in the video

To-Do (suggestions or help in implementing features are welcome):
  • Remove hard-coding and use config settings, e.g. items per page, number of pages (Don't have SVN access and that makes it cumbersome to share it)
  • Canned searches
  • Ability to select sort criteria (relevance, rating, views etc.)

stagevu.php
Code: Select all
    <?php

        /*

                (C) 2011 monkmad
                http://forum.wdlxtv.com/viewtopic.php?f=53&t=3673
   
                This StageVu plugin is designed for Zoster's USMP server which runs (amongst others)
                inside the EM7075 and DTS variant.
                This code is GPL licensed. Please read it here: http://www.gnu.org/licenses/gpl.html
                In addtion to section 7 of the GPL terms, there is one additional term :
                G) You must keep this header intact when you intend to release modified copies of the program.
   
                Thank you, and enjoy this plugin.

         */


   function writeLog($logMessage) {
     $loggingEnabled = false;
     if ($loggingEnabled) {
       $myFile = "/tmp/stagevu.log";
       $fh = fopen($myFile, 'a') or die("can't open file");
       fwrite($fh, date("d/m/y : H:i:s", time()) . " " . $logMessage . "\n");
       fclose($fh);
     }
   }

   function multi_implode($glue, $pieces)
   {
      $string='';

      if(is_array($pieces))
      {
         reset($pieces);
         while(list($key,$value)=each($pieces))
         {
            $string.=$glue.multi_implode($glue, $value);
         }
      }
      else
      {
         return $pieces;
      }

      return trim($string, $glue);
   }

    writeLog(__FUNCTION__.": "."Starting StageVu plugin log");

    function _pluginMain($prmQuery) {
      writeLog(__FUNCTION__.": "."Entering _pluginMain function");
      writeLog(__FUNCTION__.": "."prmQuery: $prmQuery");
      $queryData = array();
      parse_str($prmQuery, $queryData);
      if ($queryData['url'] !='') {
        $items = _pluginCreateVideoItems($queryData['url'],2);
        writeLog(__FUNCTION__.": "."Exiting _pluginMain function");
        return $items;
      } else {
      $items = _pluginCreateCategoryList();
      writeLog(__FUNCTION__.": "."Exiting _pluginMain function");
      return $items;
      }
    }

    function _pluginCreateCategoryList() {
      writeLog(__FUNCTION__.": "."Entering _pluginCreateCategoryList function");
      $categories = array(
        'ANIMATION' => 'Animation',
        'COMEDY' => 'Comedy',
        #'EDUCATIONAL' => 'Educational',
        'FILMS & MOVIES' => 'Films+and+Movies',
        #'GAMES' => 'Games',
        'MUSIC' => 'Music',
        'TV-SHOWS' => 'Television',
        #'OTHER' => 'Others',
        #'SPORTS' => 'Sports',
        #'NEWS & POLITICS' => 'News+and+Politics',
        'ART' => 'Art',
        'BLOGS' => 'Blogs'
      );



      foreach ($categories as $name => $id) {
        $url = "http://stagevu.com/search?keywords=&category=" . $id . "&perpage=7&sortby=relevance&ascdesc=DESC&page=" ;
        $data = array(
          'url' => ($url)
        );
        $dataString = http_build_query($data, 'pluginvar_');
        $retMediaItems[] = array (
          'id' => 'umsp://plugins/stagevu?' . $dataString,
          'dc:title' => $name,
          'upnp:class' => 'object.container',
        );
      }
      writeLog(__FUNCTION__.": "."Exiting _pluginCreateCategoryList function");
      return $retMediaItems;
    }

    function _pluginCreateVideoItems($url,$pageCount) {
     writeLog(__FUNCTION__.": "."Entering _pluginCreateVideoItems function");
     writeLog(__FUNCTION__.": "."url: $url");
     writeLog(__FUNCTION__.": "."pageCount: $pageCount");
      $retMediaItems = array();
      for ($i = 1; $i <= $pageCount; $i++) {
        writeLog(__FUNCTION__.": "."Page iteration: $i");
   array_splice($retMediaItems, count($retMediaItems), 0, stageVuGetVideosList($url.$i));
      }
      writeLog(__FUNCTION__.": "."retMediaItems: ".multi_implode(",",$retMediaItems));
      writeLog(__FUNCTION__.": "."Exiting _pluginCreateVideoItems function");
      return $retMediaItems;
    }

function _pluginSearch($prmQuery) {
    preg_match('/and dc:title contains "(.*?)"/', $prmQuery, $searchstring);
    if ( isset($searchstring[1]) ) {
        $searchUrl = "http://stagevu.com/search?keywords=" . urlencode($searchstring[1]) ."&category=&perpage=7&sortby=relevance&ascdesc=DESC&page=";
        $items = _pluginCreateVideoItems($searchUrl,2);
        return $items;
    } else {
        return null;
    }
}

function stageVuGetVideosList($stageVuSearchLink) {
   $ctx = stream_context_create(array(
       'http' => array(
      'timeout' => 60,
      'user_agent' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13'
      )
       )
   );
   //$html = file_get_contents('http://stagevu.com/search?keywords=&category=Films+and+Movies&perpage=5&sortby=relevance&ascdesc=DESC&page=1',0,$ctx);
   $html = file_get_contents($stageVuSearchLink,0, $ctx);

   $dom = new DOMDocument();
   $dom->loadHTML($html);

   $xpath = new DOMXPath($dom);

   $tags = $xpath->query('//div[@class="result1"]/div[@class="resultcont"]|//div[@class="result2"]/div[@class="resultcont"]');
   foreach ($tags as $tag) {
       $link = $tag->getElementsByTagName( "a" );
       $title = $link->item(0)->nodeValue;
       $url = $link->item(0)->getAttribute('href');

       $img = $tag->getElementsByTagName( "img" );
       $imgsrc = $img->item(0)->getAttribute('src');

       $p = $tag->getElementsByTagName( "p" );
       $ptext = $p->item(0)->nodeValue;
       $videoInfo = stageVuGetVideoInfo($url);

       $data = array(
       'mov_url' => $videoInfo["videoURL"]
       );
       $dataString = http_build_query($data, 'pluginvar_');
            $retMediaItems[] = array (
              'id' => 'umsp://plugins/stagevu?' . $dataString,
              'dc:title' => '['.$videoInfo["duration"].'] '.$title,
         'desc' => $ptext,
              'res' => $videoInfo["videoURL"],
         'duration' => '2:10:20',
              'upnp:class' => 'object.item.videoitem',
              'upnp:album_art' => $imgsrc,
              'upnp:length' => '2:10:20',
              'protocolInfo' => 'http-get:*:*:*'
            );
   }
   return $retMediaItems;
}

function stageVuGetVideoInfo($videoPageURL) {
   $return = array("videoURL" => "", "duration" => "");
   $url = "not found";
   $length = "0:0";
   $html = file_get_contents($videoPageURL);
   $dom = new DOMDocument();
   $dom->loadHTML($html);

   $xpath = new DOMXPath($dom);

   $tags = $xpath->query('//div[@id="vidbox"]/div/div/object');
   foreach ($tags as $tag) {
       $link = $tag->getElementsByTagName( "embed" );
       $url = $link->item(0)->getAttribute('src');
       break;
   }

   $tags = $xpath->query('//div[@id="infocontent"]/table/tr/td');
   foreach ($tags as $tag) {
       $length = $tag->nodeValue;
       if (preg_match('/[0-9]+[:]+[0-9]+/',$length)) {
      break;
       }
   }

   $return["videoURL"] = $url;
   $return["duration"] = $length;
   return $return;
}
   writeLog(__FUNCTION__.": "."Ending StageVu plugin log");
    ?>


/conf/umsp.php
Code: Select all
$myMediaItems[] = array(
   'id' => 'umsp://plugins/stagevu',
   'parentID' => '0',
   'restricted' => '1',
   'dc:title' => 'StageVu',
   'dc:creator' => 'monkmad',
   'dc:date'   => '2011-02-25',
   'upnp:author' => 'monkmad',
   'upnp:artist' => 'myArtist',
   'upnp:album' => 'myAlbum',
   'upnp:genre' => 'myGenre',
   'upnp:length'   => '2:10:20',
   'desc' => 'myDesc',
   'upnp:class' => 'object.container',
   'upnp:album_art'=> '',
   'duration' => 'myDur3',
   'size' => 'mySize3',
   'bitrate' => 'myBitr',
   'protocolInfo' => '*:*:*:*',
   'resolution' => 'myReso',
   'colorDepth' => 'myColor',
);
Last edited by monkmad on Fri Jun 29, 2012 11:14 am, edited 8 times in total.
monkmad
Beta Tester
 
Posts: 96
Joined: Tue Apr 20, 2010 11:31 pm

Re: Plugin: StageVu (free streaming movies)   

Postby Montreal1 » Fri Feb 25, 2011 9:00 pm

Nice one :))
Montreal1
DLX'er
 
Posts: 73
Joined: Mon Jun 07, 2010 4:09 am

Re: Plugin: StageVu (free streaming movies)   

Postby monkmad » Sat Feb 26, 2011 1:49 am

Thanks Montreal1.

One more feature I forgot to mention earlier (added to the post above now), is MediaNavigation compatibility. Once the movie starts playing, you are able to use the navigation controls to skip to any point in the movie. 8-)
monkmad
Beta Tester
 
Posts: 96
Joined: Tue Apr 20, 2010 11:31 pm

Re: Plugin: StageVu (free streaming movies)   

Postby monkmad » Sun Feb 27, 2011 3:24 am

Hmmm.... more than 250 views, dozens of downloads and no feedback (apart from 2 people). Makes me wonder if anyone found it useful and if the enhancements are worth working on. :roll:
monkmad
Beta Tester
 
Posts: 96
Joined: Tue Apr 20, 2010 11:31 pm

Re: Plugin: StageVu (free streaming movies)   

Postby nicandmih » Sun Feb 27, 2011 4:16 am

WEC suport, create a folder "stagevu" must contain:
1.stagevu.php
2.stagevu_wec.php
Code: Select all
<?php

   include ('info.php');

   // Does this WEC version support custom hooks?
   if ((defined('WECVERSION')) && (WECVERSION >= 3)) {

      include_once('/usr/share/umsp/funcs-config.php');

      // Insert badge if we have one
      if ((isset($pluginInfo['thumb']))&&($pluginInfo['thumb']!=''))
      {
         $desc = '<div style="float: left;"><img src="'.$pluginInfo['thumb'].'" width="60" height="60" alt="logo"></div>'
            .'<div>'.$pluginInfo['name']." v".$pluginInfo['version']." (".$pluginInfo['date'].") by "
            .$pluginInfo['author'].".<br>".$pluginInfo['desc']."<br>Information: <a href='".$pluginInfo['url']."'>".$pluginInfo['url']."</a>"
            .'</div>';
      }
      elseif ((isset($pluginInfo['art']))&&($pluginInfo['art']!=''))
      {
         $desc = '<div style="float: left;"><img src="'.$pluginInfo['art'].'" width="60" height="60" alt="logo"></div>'
            .'<div>'.$pluginInfo['name']." v".$pluginInfo['version']." (".$pluginInfo['date'].") by "
            .$pluginInfo['author'].".<br>".$pluginInfo['desc']."<br>Information: <a href='".$pluginInfo['url']."'>".$pluginInfo['url']."</a>"
            .'</div>';
      }
      else
      {
         $desc = $pluginInfo['name'].' v'.$pluginInfo['version'].' ('.$pluginInfo['date'].') by '
            .$pluginInfo['author'].'.<br>'.$pluginInfo['desc']."<br>Information: <a href='".$pluginInfo['url']."'>".$pluginInfo['url'].'</a>';
      }

      $key = strtoupper("{$pluginInfo['id']}_DESC");
      $wec_options[$key] = array(
         'configname'   => $key,
         'configdesc'   => $desc,
         'longdesc'   => '',
         'group'      => $pluginInfo['name'],
         'type'      => WECT_DESC,
         'page'      => WECP_UMSP,
         'displaypri'   => -25,
         'availval'   => array(),
         'availvalname'   => array(),
         'defaultval'   => '',
         'currentval'   => ''
      );

      $wec_options[$pluginInfo['id']] = array(
         'configname'   => $pluginInfo['id'],
         'configdesc'   => 'Enable '.$pluginInfo['name'].' UMSP plugin',
         'longdesc'   => '',
         'group'      => $pluginInfo['name'],
         'type'      => WECT_BOOL,
         'page'      => WECP_UMSP,
         'displaypri'   => -10,
         'availval'   => array('off','on'),
         'availvalname'   => array(),
         'defaultval'   => '',
         'currentval'   => '',
         'readhook'   => wec_umspwrap_read,
         'writehook'   => wec_umspwrap_write,
         'backuphook'   => NULL,
         'restorehook'   => NULL
      );

   }

?>


3.info.php
Code: Select all
<?php
# meta-name="StageVU"
# meta-desc="StageVU UMSP Plug-in"
# meta-author="TEAM"
# meta-date="2011-02-28"
# meta-version="0.1.5"
# meta-type="umsp"
# meta-url="http://forum.wdlxtv.com"
# meta-filename="stagevu.php"
# meta-id="stagevu"

$pluginInfo = array (
   'name'      => 'StageVU',
   'desc'      => 'StageVU',
   'author'   => 'TEAM',
   'date'      => '2011-02-28',
   'version'   => '0.1.5',
   'url'      => 'http://forum.wdlxtv.com',
   'id'      => 'stagevu',
   'thumb'      => 'http://stagevu.com/img/white/newtitle.png',
   'art'      => 'http://stagevu.com/img/white/newtitle.png',
);
?>

4.config.php
Code: Select all
<?php

   // info contains meta data and plug-in configuration attributes
   include('info.php');

   # _DONT_RUN_CONFIG_ gets set by external scripts that just want to get the pluginInfo array via include() without running any code. Better solution?
   if ( !defined('_DONT_RUN_CONFIG_') )
   {

      include_once('/usr/share/umsp/funcs-config.php');
      # Check for a form submit that changes the plugin status:
      if ( isset($_GET['pluginStatus']) )
         $writeResult = _writePluginStatus($pluginInfo['id'], $_GET['pluginStatus']);

      # Read the current status of the plugin ('on'/'off') from conf
      $pluginStatus = _readPluginStatus($pluginInfo['id']);

      # New or unknown plugins return null. Add special handling here:
      if ( $pluginStatus === null )
         $pluginStatus = 'off';

      # _configMainHTML generates a standard plugin dialog based on the pluginInfo array:
      $retHTML = _configMainHTML($pluginInfo, $pluginStatus);
      echo $retHTML;

      # Add additonal HTML or code here

      # _configMainHTML doesn't return end tags so add them here:
      echo '</body>';
      echo '</html>';
   }

?>



5. copy this folder in UMSP PLUGINS and activate

enjoy
nicandmih
Donor
 
Posts: 270
Joined: Sun Apr 11, 2010 10:46 am
Location: Romania, Constanta

Re: Plugin: StageVu (free streaming movies)   

Postby monkmad » Sun Feb 27, 2011 4:53 am

Great job, nicandmih; thx!

I'd just finished a quick and dirty version with sort capabilities, but I'll modify it now to take advantage of WEC to set parameters like number of items to fetch, search sort criteria etc.. ;)
monkmad
Beta Tester
 
Posts: 96
Joined: Tue Apr 20, 2010 11:31 pm

Re: Plugin: StageVu (free streaming movies)   

Postby monkmad » Sun Feb 27, 2011 6:31 am

Posted new version with sort, webend config et al. Check first post for link.
monkmad
Beta Tester
 
Posts: 96
Joined: Tue Apr 20, 2010 11:31 pm

Re: Plugin: StageVu (free streaming movies)   

Postby nicandmih » Sun Feb 27, 2011 8:52 am

New version it`OK but that happend thanks to you and do not forget :martinmocv . see you
nicandmih
Donor
 
Posts: 270
Joined: Sun Apr 11, 2010 10:46 am
Location: Romania, Constanta

Re: Plugin: StageVu (free streaming movies)   

Postby monkmad » Sun Feb 27, 2011 9:19 am

nicandmih wrote:New version it`OK but that happend thanks to you and do not forget :martinmocv . see you


Maybe I don't understand what you are trying to say; but it sure sounds like you are also giving credit to someone who just asked a question about a plugin's availability? :?
monkmad
Beta Tester
 
Posts: 96
Joined: Tue Apr 20, 2010 11:31 pm

Re: Plugin: StageVu (free streaming movies)   

Postby nicandmih » Sun Feb 27, 2011 9:48 am

Sorry, me english it`s not so god, but i want to sai I do not make something dificult.

For example i so IPLA plugin from gabriel wrong plugin (do not have a god start) i can change what is plaing if i take id from the site but i can t modify, the plugin. -this is dificult.
nicandmih
Donor
 
Posts: 270
Joined: Sun Apr 11, 2010 10:46 am
Location: Romania, Constanta

Next

Return to UMSP Plugins

Who is online

Users browsing this forum: No registered users and 2 guests

cron