Sign up here and you can log into the forum!

UMSP Plugin :: Revision3

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

UMSP Plugin :: Revision3   

Postby shunte » Mon Oct 18, 2010 7:01 am

Rev3 has added a couple of new shows over the last couple of weeks which once again put the list of plug-in supported shows out of sync.

I took a peek at the rev3 site and found that it was simple enough to pull past and present shows dynamically inclusive of their thumbnails

here is the updated plug-in
** edit : minor edit from original post removing a little code bloat ;) **
Code: Select all
<?php

    # (C) 2010 Alex Meijer for Eminent Europe B.V.
    #
    # Revision: modified to pull contents from rev3 shows listings inclusive of show art - shunte
    #
    # This revision3 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 _pluginMain($prmQuery) {
       
        // This function is started if user clicks on the 'Revision3' option in the menu
        // It has no parameters and will run 'PluginCreateFeedlist' that returns an array with feeds.
        // If run with a feed (/revision3.php?feed=animetv) it will run the function _pluginFeedResolution
        // and if run with both present, it will return a list of items in the respective feed.
       
        $queryData = array();
        parse_str($prmQuery, $queryData);
        if ($queryData['feed'] !='') {
            $items = _pluginFeedResolution($queryData['feed']);
            return $items;
        } else {
            if ($queryData['itemurl'] !='') {
                $items = _pluginCreateVideoItems($queryData['itemurl']);
                return $items;
            } else {
                $items = _pluginCreateFeedList();
                return $items;
            } # end if
        }
    } # end function

    function _scrapeShowsHTML($url,&$shows,&$image_url) {

        // we can get shows from the following URL, won't give us archived shows though!
        // page scrape method gives show name, URL, desc, thumb and a level of dynamacicity (sp?)
        //http://revision3.com/shows
        // archived (no longer associated or in production) can be found here
        //http://revision3.com/shows/archive

        $html = file_get_contents($url);
        // showz contains upart">title, we'll substing for comps ...
        preg_match_all('/<h3><a href="\/(.*?)<\/a><\/h3>/',$html,$shows);
        preg_match_all('/" class="thumbnail"><img src="(.*?)" \/><\/a>/',$html,$image_url);
    }

    function _pushMediaItems($shows,$image_url,$exclude_shows,$boiler,&$retMediaItems) {
        if(sizeof($shows[1])!=0) {
            for ($z = 0; $z < sizeof($shows[1]); $z++)
            {
                $upart = trim(substr($shows[1][$z],0,strpos($shows[1][$z],'">')));
                $title = trim(substr($shows[1][$z],strpos($shows[1][$z],'">')+2));
                $pos = strpos($exclude_shows, $upart.'|');
                if ($pos === false) {
                    $retMediaItems[] = array (
                                       'id'         => 'umsp://plugins/revision3?feed=' . $upart,
                                       'dc:title'   => $boiler.' ('.$title.')',
                                       'res'        => 'umsp://plugins/revision3?feed=' . $upart,
                                       'upnp:class' => 'object.container',
                                       'upnp:album_art'=>$image_url[1][$z],
                                      ); // end array building
                } // end if
            } // end for
        } // end if
    }

    function _pluginCreateFeedList($feed){

        // exclude anything we have no interest in via config
        $config = file_get_contents('/conf/config');
        preg_match('/REV3_EXCLUDE_SHOWS=\'(.+)\'/', $config, $m);
        $exclude_shows = strtolower($m[1].'|');
        // only process archiveed if requested (off by default)
        preg_match('/REV3_INCLUDE_ARCHIVE=\'(.+)\'/', $config, $m);
        $inc_archve_shows = $m[1];

        // parse shows via revision3 shows html
        _scrapeShowsHTML('http://revision3.com/shows',$shows,$image_url);
        _pushMediaItems($shows,$image_url,$exclude_shows,'Revision3',$retMediaItems);

        if($inc_archve_shows=='ON') {
            _scrapeShowsHTML('http://revision3.com/shows/archive',$shows,$image_url);
            _pushMediaItems($shows,$image_url,$exclude_shows,'Revision3 Archive',$retMediaItems);
        } // end if

        return $retMediaItems;
    } // end function

    function _pluginFeedResolution($feed) {
       
        // Create the actual XML feed url with resolution selection added at the end.
        // Create variants from $feed: ($feed holds the name, hak5 for ex.)
       
        $baseurl = 'http://revision3.com/';
        $basereso = '/feed/MP4-Large';
        $baseStr = '/feed/MP4-Large';
        $feedurl = $baseurl . $feed . $basereso;
        $subshow = '';
        if ($feed == 'tekzilla') {
            // if we want tekzilla daily then subshow arg should be passed (actually default is on)
            //http://revision3.com/tekzilla/feed/Xvid-Large?subshow=false
            $config = file_get_contents('/conf/config');
            preg_match('/REV3_DAILY_SHOWS=\'(.+)\'/', $config, $m);
            $daily_shows = $m[1];
            if($daily_shows=='ON') {
                $subshow = '?subshow=true';
            } else {
                $subshow = '?subshow=false';
            }
        }
        $variants[] = array('desc' => 'Small',   'ext' => '/feed/MP4-Small');
        $variants[] = array('desc' => 'Large',   'ext' => '/feed/MP4-Large');
        $variants[] = array('desc' => 'HD 720p', 'ext' => '/feed/MP4-High-Definition');
        foreach ($variants as $variant) {
            $itemURL = str_replace($baseStr, $variant['ext'].$subshow, $feedurl);
            $data = array(
                        'itemurl' => $itemURL,
                    );
            $dataString = http_build_query($data, 'pluginvar_');
            $retMediaItems[] = array (
                                   'id'         => 'umsp://plugins/revision3?'.$dataString,
                                   'dc:title'   => $variant['desc'],
                                   'res'        => 'umsp://plugins/revision3?'.$dataString,
                                   'upnp:class' => 'object.container',
                               );
        } # end foreach
        return $retMediaItems;
    } # end function

    function _pluginCreateVideoItems($prmQuery) {

        $reader = new XMLReader();
        $episodelistXML = file_get_contents($prmQuery);
        $reader->XML($episodelistXML);
        while ($reader->read()) {
            if ($reader->nodeType == XMLReader::ELEMENT) {
                if ($reader->localName == 'title') {
                    $title = $reader->readString ('title');
                } # end if
                if ($reader->localName == 'enclosure') {
                    $location = $reader->getAttribute('url');
                    $data = array(
                                'url' => $location,
                            );
                    $dataString = http_build_query($data, 'pluginvar_');
                    $retMediaItems[] = array (
                                           'id'            => 'umsp://plugins/revision3?' . $dataString,
                                           'dc:title'      => $title,
                                           'res'           => $location,
                                           'upnp:class'    => 'object.item.videoitem',
                                           'protocolInfo'  => 'http-get:*:video/mp4:*',
                                       );
                } # end if
            } # end if
        } #end while
        return $retMediaItems;
    } # end function

?>


I've copied the plug-in to my thumb drive and added the following to the end of my net.mounts to override the built-in rev3 plug-in
Code: Select all
# my dynamic revision3
mount -o bind /tmp/media/usb/{your thumb local here}/revision3.php /usr/share/umsp/plugins/revision3.php

refer to this posting for other options, also apologies to liskl for the undo

http://forum.wdlxtv.com/viewtopic.php?f=49&t=1702&p=13787

given those combined show lists yield over 50 entries I've added some configuration to turn various aspects of processing off
these settings are my examples only, the default is to have everything 'on'
Code: Select all
config_tool -c REV3_INCLUDE_ARCHIVE='ON'
config_tool -c REV3_DAILY_SHOWS='ON'
config_tool -c REV3_EXCLUDE_SHOWS='hak5|appjudgment|bytejacker|dan30|destructoid|ifanboy|rofl|foodmob'

REV3_INCLUDE_ARCHIVE - turns archived shows on or off - default is ON
REV3_DAILY_SHOWS - turns Tekzilla daily shows on or off - default is ON
REV3_EXCLUDE_SHOWS - pipe delimited list of shows you don't want to see - default is no exclusion

here is the _WEC for these parameters should you need it
Code: Select all
<?php
/***    Revision3 plugin
***/

$wec_options['REV3_INCLUDE_ARCHIVE'] = array('configname' => 'REV3_INCLUDE_ARCHIVE',
                    'configdesc' => "Include archived (no longer in production) shows on Rev3:",
                    'longdesc' => "Default: On",
                    'group' => 'Revision3 Plugin',
                    'type' => WECT_BOOL,
                    'page' => WECP_WDTVEXT,
                    'defaultval' => 'ON',
                    'currentval' => '');
$wec_options['REV3_EXCLUDE_SHOWS'] = array('configname' => 'REV3_EXCLUDE_SHOWS',
                    'configdesc' => "Specify pipe delimited list of Rev3 shows to exclude:",
                    'longdesc' => "Default: |",
                    'group' => 'Revision3 Plugin',
                    'type' => WECT_TEXT,
                    'page' => WECP_WDTVEXT,
                    'defaultval' => '|',
                    'currentval' => '');
$wec_options['REV3_DAILY_SHOWS'] = array('configname' => 'REV3_DAILY_SHOWS',
                    'configdesc' => "Include Daily shows in the Rev3 listings:",
                    'longdesc' => "Default: On",
                    'group' => 'Revision3 Plugin',
                    'type' => WECT_BOOL,
                    'page' => WECP_WDTVEXT,
                    'defaultval' => 'ON',
                    'currentval' => '');
?>


enjoy!
Last edited by shunte on Mon Mar 07, 2011 5:20 pm, edited 2 times in total.
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: Revision3 Revisited [Again Sorry]   

Postby shunte » Tue Oct 19, 2010 7:08 am

Minor update to the code as I noticed a "phantom" empty thumb at the end of the shows listing

This is a one line change but I'm posting the entire listing for simplicity

Code: Select all
<?php

    # (C) 2010 Alex Meijer for Eminent Europe B.V.
    #
    # Revision: modified to pull contents from rev3 shows listings inclusive of show art - shunte
    #
    # This revision3 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 _pluginMain($prmQuery) {
       
        // This function is started if user clicks on the 'Revision3' option in the menu
        // It has no parameters and will run 'PluginCreateFeedlist' that returns an array with feeds.
        // If run with a feed (/revision3.php?feed=animetv) it will run the function _pluginFeedResolution
        // and if run with both present, it will return a list of items in the respective feed.
       
        $queryData = array();
        parse_str($prmQuery, $queryData);
        if ($queryData['feed'] !='') {
            $items = _pluginFeedResolution($queryData['feed']);
            return $items;
        } else {
            if ($queryData['itemurl'] !='') {
                $items = _pluginCreateVideoItems($queryData['itemurl']);
                return $items;
            } else {
                $items = _pluginCreateFeedList();
                return $items;
            } # end if
        }
    } # end function

    function _scrapeShowsHTML($url,&$shows,&$image_url) {

        // we can get shows from the following URL, won't give us archived shows though!
        // page scrape method gives show name, URL, desc, thumb and a level of dynamacicity (sp?)
        //http://revision3.com/shows
        // archived (no longer associated or in production) can be found here
        //http://revision3.com/shows/archive

        $html = file_get_contents($url);
        // showz contains upart">title, we'll substing for comps ...
        preg_match_all('/<h3><a href="\/(.*?)<\/a><\/h3>/',$html,$shows);
        preg_match_all('/" class="thumbnail"><img src="(.*?)" \/><\/a>/',$html,$image_url);
    }

    function _pushMediaItems($shows,$image_url,$exclude_shows,$boiler,&$retMediaItems) {
        if(sizeof($shows[1])!=0) {
            for ($z = 0; $z < count($shows[1]); $z++)
            {
                $upart = trim(substr($shows[1][$z],0,strpos($shows[1][$z],'">')));
                $title = trim(substr($shows[1][$z],strpos($shows[1][$z],'">')+2));
                $pos = strpos($exclude_shows, $upart.'|');
                if ($pos === false) {
                    $retMediaItems[] = array (
                                       'id'         => 'umsp://plugins/revision3?feed=' . $upart,
                                       'dc:title'   => $boiler.' ('.$title.')',
                                       'res'        => 'umsp://plugins/revision3?feed=' . $upart,
                                       'upnp:class' => 'object.container',
                                       'upnp:album_art'=>$image_url[1][$z],
                                      ); // end array building
                } // end if
            } // end for
        } // end if
    }

    function _pluginCreateFeedList($feed){

        // exclude anything we have no interest in via config
        $config = file_get_contents('/conf/config');
        preg_match('/REV3_EXCLUDE_SHOWS=\'(.+)\'/', $config, $m);
        $exclude_shows = strtolower($m[1].'|');
        // only process archiveed if requested (off by default)
        preg_match('/REV3_INCLUDE_ARCHIVE=\'(.+)\'/', $config, $m);
        $inc_archve_shows = $m[1];

        // parse shows via revision3 shows html
        _scrapeShowsHTML('http://revision3.com/shows',$shows,$image_url);
        _pushMediaItems($shows,$image_url,$exclude_shows,'Revision3',$retMediaItems);

        if($inc_archve_shows=='ON') {
            _scrapeShowsHTML('http://revision3.com/shows/archive',$shows,$image_url);
            _pushMediaItems($shows,$image_url,$exclude_shows,'Revision3 Archive',$retMediaItems);
        } // end if

        return $retMediaItems;
    } // end function

    function _pluginFeedResolution($feed) {
       
        // Create the actual XML feed url with resolution selection added at the end.
        // Create variants from $feed: ($feed holds the name, hak5 for ex.)
       
        $baseurl = 'http://revision3.com/';
        $basereso = '/feed/MP4-Large';
        $baseStr = '/feed/MP4-Large';
        $feedurl = $baseurl . $feed . $basereso;
        $subshow = '';
        if ($feed == 'tekzilla') {
            // if we want tekzilla daily then subshow arg should be passed (actually default is on)
            //http://revision3.com/tekzilla/feed/Xvid-Large?subshow=false
            $config = file_get_contents('/conf/config');
            preg_match('/REV3_DAILY_SHOWS=\'(.+)\'/', $config, $m);
            $daily_shows = $m[1];
            if($daily_shows=='ON') {
                $subshow = '?subshow=true';
            } else {
                $subshow = '?subshow=false';
            }
        }
        $variants[] = array('desc' => 'Small',   'ext' => '/feed/MP4-Small');
        $variants[] = array('desc' => 'Large',   'ext' => '/feed/MP4-Large');
        $variants[] = array('desc' => 'HD 720p', 'ext' => '/feed/MP4-High-Definition');
        foreach ($variants as $variant) {
            $itemURL = str_replace($baseStr, $variant['ext'].$subshow, $feedurl);
            $data = array(
                        'itemurl' => $itemURL,
                    );
            $dataString = http_build_query($data, 'pluginvar_');
            $retMediaItems[] = array (
                                   'id'         => 'umsp://plugins/revision3?'.$dataString,
                                   'dc:title'   => $variant['desc'],
                                   'res'        => 'umsp://plugins/revision3?'.$dataString,
                                   'upnp:class' => 'object.container',
                               );
        } # end foreach
        return $retMediaItems;
    } # end function

    function _pluginCreateVideoItems($prmQuery) {

        $reader = new XMLReader();
        $episodelistXML = file_get_contents($prmQuery);
        $reader->XML($episodelistXML);
        while ($reader->read()) {
            if ($reader->nodeType == XMLReader::ELEMENT) {
                if ($reader->localName == 'title') {
                    $title = $reader->readString ('title');
                } # end if
                if ($reader->localName == 'enclosure') {
                    $location = $reader->getAttribute('url');
                    $data = array(
                                'url' => $location,
                            );
                    $dataString = http_build_query($data, 'pluginvar_');
                    $retMediaItems[] = array (
                                           'id'            => 'umsp://plugins/revision3?' . $dataString,
                                           'dc:title'      => $title,
                                           'res'           => $location,
                                           'upnp:class'    => 'object.item.videoitem',
                                           'protocolInfo'  => 'http-get:*:video/mp4:*',
                                       );
                } # end if
            } # end if
        } #end while
        return $retMediaItems;
    } # end function

?>
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: Revision3 Revisited [Again Sorry]   

Postby charmr » Wed Oct 20, 2010 1:21 am

nvm
charmr
Donor
 
Posts: 21
Joined: Sat Jul 24, 2010 6:18 am

Re: Revision3 Revisited [Again Sorry]   

Postby b-rad.cc » Sun Oct 24, 2010 4:51 pm

this has been committed. cheers. :geek:
PM's are for private matters only, please post public matters on the forum to help others who might have the same issue.
:mrgreen:
User avatar
b-rad.cc
WDLXTV Team
 
Posts: 3003
Joined: Sat Apr 03, 2010 9:35 am
Location: New York

Re: Revision3 Revisited [Again Sorry]   

Postby shunte » Mon Mar 07, 2011 1:57 pm

Ever wanted to go from here
Image
to here
Image
without going through here?
Image

while I'm proud of my Rev3 coffee cup images, poking a little fun at Starbuck's cup sizes, I for one am tired of having to click on one of them to see a Rev3 show, so...

Fast-track menuing has been added by selecting your media resolution preference through WEC, by default there is no change and you manually have to pick

In addition a Today On Revision3 menu option has been exposed so you can go to today's shows only - should you not know the Rev3 schedule by heart
Image
This later addition needs a little more work to fast-track the menus a little further so you go directly to the current show

By default this option is off, it can be enabled through WEC

Anyway, I hope you like these additions

And for those that hadn't noticed I added episode art on a prior release a week or so ago ;)

Updated plug-in is available though SVN via the usual mechanisms

Enjoy!
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 Plugin :: Revision3   

Postby muathib » Fri Oct 28, 2011 10:52 am

Hello! I just decided to hack my WDTV Live+ this morning, and I just wanted to say what a great job you've done with this plugin! I was just wondering if there was any way to edit the number of episodes that get pulled in? Sometimes I like to go back and re-watch past episodes and I was just wondering if there was any setting or anything that could let me do that? Thanks in advance for your help and great work.
muathib
n00b
 
Posts: 1
Joined: Fri Oct 28, 2011 10:50 am

Re: UMSP Plugin :: Revision3   

Postby shunte » Sun Oct 30, 2011 10:12 am

the plug-in presents the current "tip" of shows as exposed in the Rev3 feeds so we get a rolling fixed number

I added search a while back; if it isn't working too well let me know

I'll also take a look at adding "canned" search and saved programing via a configuration mechanism
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 Plugin :: Revision3   

Postby Raven » Sun Dec 18, 2011 10:01 am

That search actually doesn't work that well. Or maybe I just don't know how to use it. Basically what I did was search for an old show by the title of the episode. I found the name of the episode on their website, put it into the search and hit submit. The hits I got back had nothing to do with the search. If that could be improved, that'd be awesome.
Raven
n00b
 
Posts: 14
Joined: Mon Apr 19, 2010 12:38 pm

Re: UMSP Plugin :: Revision3   

Postby shunte » Sun Dec 18, 2011 12:36 pm

The current implementation utilizes the tags associated to a show

I'll look into adding additional search mechanisms over the Christmas break if I can find the time
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 Plugin :: Revision3   

Postby Raven » Sun Dec 18, 2011 1:12 pm

Where can I find those tags? I'm looking on the episode's page and I'm not seeing tags anywhere. If I could find them and get the right hits, the search will at least be usable for now.
Raven
n00b
 
Posts: 14
Joined: Mon Apr 19, 2010 12:38 pm

Next

Return to UMSP Media Server

Who is online

Users browsing this forum: No registered users and 3 guests