Sign up here and you can log into the forum!

my next crazy idea - trailers

General WDTVExt forum

Re: my next crazy idea - trailers   

Postby KAD » Wed Feb 01, 2012 8:35 pm

ok, this should not be too difficult, but I'm stumped :?

example responseText
Code: Select all
<!DOCTYPE html>
<html>
<head>
  <title>IMDb Video Player: The Dark Knight</title>

  <link rel="stylesheet" type="text/css" href="http://i.media-imdb.com/images/SFc07b1c1f8fc4fedd710b066162afcba7/css/min/html5player.css" >
</head>
<body id="video-player-body">


<div id="video-player-container">
    <div id="video-title-hover" class="html5player-hover">
      <div class="v-p-horizontal-spacer"></div>
        The Dark Knight
    </div>

<div id="video-player" >
        <noscript>
            <span class="error">
                Sorry! In order to play this video, you must have JavaScript enabled.
            </span>
        </noscript>
    </div>
</div>



         


<script src="http://i.media-imdb.com/images/SF7e0791f9fc3d5c7c1a0c2366fad57de6/js/jquery.js" ></script>
<script src="http://i.media-imdb.com/images/SFe4258aff163c4740a6eb6a53141eb12a/js/jquery/ui-current.js" ></script>
<script src="http://i.media-imdb.com/images/SF66d41ec7090bbdde87e09a309dea6661/js/swfobject/1.5.js" ></script>
<script src="http://i.media-imdb.com/images/SF93b7e74d135b3271c84b06351bd92afb/js/cc/widget/html5player.js" ></script>
<script type="text/javascript">jQuery(function(){
    jQuery('#video-player').html5player({
        logger : function (txt){
            if (window.console && window.console.log){
                console.log(txt);
            }
        },
        streams : {
            mp4_h264    : 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e43433&bitrateid=472&vendorid=102&type=.mp4'
        },
        callback: 'metrics',
        slate   : 'http://ia.media-imdb.com/images/M/MV5BOTE4NTY5MzUyMF5BMl5BanBnXkFtZTcwNDc1MjIwMg@@._V1_.jpg',
        width   : '854',
        height  : '480',
        flash   : {
            player      : '/images/js/app/video/mediaplayer.swf',
            flash_vars  : {
                file        : 'http%3A%2F%2Fwww.totaleclips.com%2FPlayer%2FBounce.aspx%3Feclipid%3De43433%26bitrateid%3D472%26vendorid%3D102%26type%3D.mp4',
                id          : ''
            }
        },
        autostart: true
    });
});
jQuery('#prev-button-background').bind('click', function(){
        jQuery('#video-player').trigger('previousVideo');
});
jQuery('#next-button-background').bind('click', function(){
        jQuery('#video-player').trigger('nextVideo');
});
</script>
<!-- h=iop719 i=2012-02-01 s=legacy(default) t='Wed Feb  1 19:41:48 2012' -->
</body>
</html>


If I do this, I can see the full HTML in log
Code: Select all
if (curl3.perform()) {
      var StreamHTML = curl3.responseText;
      this.debug.Log("[ getstreams]" + StreamHTML, 2);


I've tried eval, and can only seem to get "undefined"
I've tried a lot of other options, which don't run at all

also it seems that some streams will need to be split and other not
above response text, does not need split,

but anything like this does
Code: Select all
http://www.video-http.media-imdb.com/MV5BMTYzODY1MTAxOF5BMTFeQW1wNF5BbWU3MDEyNTkyMzM@.mp4?Expires=1328169343&Signature=O0PE79bFTQjbtCVBmwvFL49AiOKQZEiPWJiTUDfQISzAKsiM1ULiZDRWvgQsSAjhHoDj6e8pns1QLgrLqKfR~PooydK4F0a2b-aEcMGCy3KRc6KjYdjSPsvmEgB7-N1AgcH3YcZ3I~fVlPLGWElBMqsOCzs2cIWGXd0LTJGTWuM_&Key-Pair-Id=APKAILW5I44IHKUN2DYA&hint=flv


please clues/help
it's frustrating to be so close, but yet just out of reach

KAD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
User avatar
KAD
Global Moderator
 
Posts: 4006
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby mad_ady » Thu Feb 02, 2012 12:04 am

If you have the output above, the best way to extract is is by using regular expressions on the output string. Something like (untested):

Code: Select all
file        : 'http%3A%2F%2Fwww.totaleclips.com%2FPlayer%2FBounce.aspx%3Feclipid%3De43433%26bitrateid%3D472%26vendorid%3D102%26type%3D.mp4',


Code: Select all
file\s+:\s+\'([^\']+)\'


You would be using something like
Code: Select all
htmlString.match(/file\s+:\s+\'([^\']+)\'/);
var url= RegExp.$1;


http://www.regular-expressions.info/javascript.html
Hope this helps
User avatar
mad_ady
Developer
 
Posts: 2996
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: my next crazy idea - trailers   

Postby KAD » Thu Feb 02, 2012 10:16 am

no that helps a lot, now at least I know what I should be trying to use

of coarse, I'm at work and have to wait till I'm home to play with it

KAD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
User avatar
KAD
Global Moderator
 
Posts: 4006
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby KAD » Thu Feb 02, 2012 8:07 pm

well, I had so hoped that would be it, a slight edit to the regexp above and I'm getting a valid response, but now I can't play it back

so here's some of what I'm getting

dmaosd.log shows I'm getting correct entry from regexp
Code: Select all
Trailer: [ getstreams]http://video-http.media-imdb.com/MV5BMTYzODY1MTAxOF5BMTFeQW1wNF5BbWU3MDEyNTkyMzM@.mp4?Expires=1328273635&Signature=OUjIqhlvbgQci-BAnGVllDP2QNd4aQ63XQfbGMN0AgbSpsK3aw5QjUumInqWPIonFKcb5Z1r0jsU4sgg~~MyrflM0Oib7jaE6yircYeAiuj2GtYtGth5r5LuwUjicIjJMiKjQGJ4aZXlkJg4ifYm6W9wRSJo5FCl~R5g2~0NyOA_&Key-Pair-Id=APKAILW5I44IHKUN2DYA&hint=flv

and here's what I get when trying to play it
Code: Select all
Lib: [executeCmd]  cmd: play "http://video-http.media-imdb.com/MV5BMTYzODY1MTAxOF5BMTFeQW1wNF5BbWU3MDEyNTkyMzM@.mp4?Expires=1328273715&Signature=x61Tqb85FcySyRU80cbne285o1vXyyPejecdBcvURE2oqlqEvQcn-rmsy0gYCXxhRV2rN4I5CviPdJU1GmRPGUww9JMOc1yxzcWjtQoMFD27KzlGgROQvOaP8kMoNgOSq5QOamkdJoC9Q5OAERih6Gc0fGVnGgklcVqhO7~GS04_&Key-Pair-Id=APKAILW5I44IHKUN2DYA&hint=flv"
Lib: [executeCmd]  > [faultcode] => s:Client
Lib: [executeCmd]  > [faultstring] => UPnPError
Lib: [executeCmd]  > [detail] => 402Illegal value
Lib: [executeCmd]  completed.


initially, I thought I would cut this down to after the .mp4 so that upnp-cmd would accept it
which it does help, if I do that upnp-cmd stops complaining about the illegal value
however it still doesn't play

so I plugged that into a browser and got this response
Code: Select all
MissingKeyMissing Key-Pair-Id query parameter


so it seems, if I cut the string down, upnp-cmd will accept it
but if I cut the string, access is denied

so now I'm wondering if anybody has idea's
how would you play this back - note I'm initiating play back with onkeypress while browsing local drives

how does umsp playback url's like this?

I did take a look at the imdb trailers plugin and saw that it's running this
Code: Select all
config_tool -c IMDBTRAILERS_$key='$value' >/dev/null 2>&1"

it seems storing the key-Pair-id to conf/config but actually, it's being redirected to /dev/null and not writing anything to /conf/config

KAD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
User avatar
KAD
Global Moderator
 
Posts: 4006
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby KAD » Thu Feb 02, 2012 9:59 pm

ok, took a break,
I could swear I tested this manually before writing all this, so back to some manual testing and here's what I learned

upnp-meta does not work with http addresses, it only works with local files
so this means a couple of things
1 no meta data = must play some video first otherwise video will play in the background
2 play script first calls upnp-meta = so can't use the play script

so for those that know what to do with it, here is a very early alpha version
press the stop button to start playback
default resolution is 240p,
valid options are 240p, 480p,720p
Code: Select all
// Trailer Plugin WDTVExt plugin by KAD (2011)
//
//
/*
# meta-name="Trailer"
# meta-desc="WDTVExt Trailer"
# meta-author="KAD"
# meta-date="2012-02-02"
# meta-version="1.0.0"
# meta-type="wdtvext"
# meta-url="http://forum.wdlxtv.com"
# meta-filename="Trailer.plugin.js"
*/
traceln("Start loading Trailer Plugin");

function TrailerPlugin(path) {
   this.rootPath = path;
   this.debug = new Debug();
   this.debug.Enable = true;
   this.debug.Prefix = "Trailer:";
   var dLevel = getConfigSetting("Trailer_DEBUG");
   this.debug.Level = (dLevel === "") ? 0 : dLevel;
   this.debug.Level = 5;
   this.debug.Lib = (this.debug.Level > 2) ? this.debug.Level - 2 : 0;
   this.coverShow = false;
   this.debug.Log(" path: " + this.rootPath, 1);
   this.SearchName = "SearchName";
   this.SearchStream = "IMDBID";
   this.trailerid = "TrailerID";
   this.currentTrailer = "Trailer"
   this.Format = getConfigSetting("TRAILER_RESOLUTION",this.debug.Lib);
   
   var result1 = executeCmd("mount -o bind " + this.rootPath + "bin/play /usr/bin/play");
   var result2 = executeCmd("mount -o bind " + this.rootPath + "bin/upnp-cmd /usr/bin/upnp-cmd");
   var result3 = executeCmd("mount -o bind " + this.rootPath + "bin/upnp-meta /usr/bin/upnp-meta");
}

TrailerPlugin.prototype = new Plugin()
TrailerPlugin.prototype.constructor = TrailerPlugin;

TrailerPlugin.prototype.onPageKey = function(page, key) {
   this.debug.Log("[onPageKey] page: " + page.markupFileName + "   key: " + key, 2);
   if (page.isMediaListPage) {
      if ((page.markupFileName === "basic_browse.xml") ||
      (page.markupFileName === "basic_browse_thumb_video.xml") ||
      (page.markupFileName === "basic_browse_thumb.xml")) {
      this.debug.Log("[ onPageKey ] (isMediaListPage) key: " + key, 1);
      this.setSearchName(page);
      if (key == 38 || key == 40)
         this.selectionFix();
      if (key == 41)
         this.playTrailer();
      }
   }
}

TrailerPlugin.prototype.playTrailer = function() {
   var Trailer = this.currentTrailer;
   res1 = executeCmd("upnp-cmd SetAVTransportURI \"" + Trailer +"\"",2);
   res2 = executeCmd("upnp-cmd Play", 3);
   this.debug.Log("  playTrailer: " + Trailer, 3);
}

TrailerPlugin.prototype.selectionFix = function() {
   this.debug.Log("[ selectionFix ]", 2);
   system("oneDelaySelectionFix");
}

TrailerPlugin.prototype.setSearchName = function(page) {
   this.debug.Log("[ setSearchName ]", 1);
   Page.Top.setParam("SearchName", "");
   var media = page.selectedMedia;
   if (!media || media == "") {
      return;
   }
   var SearchName = "";
   if (media) {
      if (media.path.lastIndexOf('/') === media.path.length-1) {
         SearchName = (media.name);
         this.debug.Log("[ setSearchName folder name]" + SearchName, 1);
         Page.Top.setParam("SearchName", SearchName);
         this.SearchName = SearchName;
         this.debug.Log("[ setSearchName folder path]" + media.path, 1);
         var metafile = (media.path + media.name + ".tgmd");
         var NameSearchURL = ("http://app.imdb.com/find?q=" + SearchName);
         this.debug.Log("[ getimdbid curl ]" + NameSearchURL, 2);
         var curl = new CurlEasy(NameSearchURL);
         if (curl.perform()) {
            var content = eval("(" + curl.responseText + ")");
            var result = content.data.results[0];
            var lists = result.list[0];
            var IMDBID = lists.tconst;
            this.debug.Log("[ getimdbid IMDBID]" + IMDBID, 2);
         }
         this.SearchStream = IMDBID;
         var SearchID = ("http://app.imdb.com/title/maindetails?tconst=" + IMDBID);
         this.debug.Log("[ getstreamid curl ]" + SearchID, 2);
         var curl2 = new CurlEasy(SearchID);
         if (curl2.perform()) {
            var content2 = eval("(" + curl2.responseText + ")");
            var title = content2.data.title;
            var TrailerID = content2.data.trailer.id;
            this.debug.Log("[ getstreamid]" + TrailerID, 2);
         }
         this.trailerid = TrailerID;
      } else {
         file = (media.name);
         SearchName = file.substr(0, file.lastIndexOf('.'));
         this.debug.Log("[ setSearchName file name]" + SearchName, 1);
         Page.Top.setParam("SearchName", SearchName);
         this.SearchName = SearchName;
         var metafile = (media.path + ".tgmd");
         var NameSearchURL = ("http://app.imdb.com/find?q=" + SearchName);
         this.debug.Log("[ getimdbid curl ]" + NameSearchURL, 2);
         var curl = new CurlEasy(NameSearchURL);
         if (curl.perform()) {
            var content = eval("(" + curl.responseText + ")");
            var result = content.data.results[0];
            var lists = result.list[0];
            var IMDBID = lists.tconst;
            this.debug.Log("[ getimdbid IMDBID]" + IMDBID, 2);
            this.SearchStream = IMDBID;
         }
         var SearchID = ("http://app.imdb.com/title/maindetails?tconst=" + IMDBID);
         this.debug.Log("[ getstreamid curl ]" + SearchID, 2);
         var curl2 = new CurlEasy(SearchID);
         if (curl2.perform()) {
            var content2 = eval("(" + curl2.responseText + ")");
            var title = content2.data.title;
            var TrailerID = content2.data.trailer.id;
            this.debug.Log("[ getstreamid]" + TrailerID, 2);
         }
         this.trailerid = TrailerID;
      }
   }
   if (this.Format == "") {
      this.Format = "240p";
   }
   var URL = ("http://www.imdb.com/video/imdb/" + this.trailerid + "/html5?format=" + this.Format);
   this.debug.Log("[ getstreamid]" + URL, 2);
   this.URL = URL;
   var curl3 = new CurlEasy(URL);
   if (curl3.perform()) {
      var StreamHTML = curl3.responseText;
      StreamHTML.match(/mp4_h264\s+:\s+\'([^\']+)\'/);
      var Trailer = RegExp.$1;
      this.currentTrailer = Trailer;
      this.debug.Log("[ getstreams]" + Trailer, 2);
   }
}

TrailerPlugin.instance = new TrailerPlugin(scriptPath);
Plugin.registerPlugin(TrailerPlugin.instance);
traceln("End loading Trailer Plugin");


here's the rather large to do list
create on screen feedback on if trailer is available
create system for catching if get imdb ID fails,
- if fail, disable on screen feedback
- if successful update on screen feedback (I thinking icon, or text, possibly, include trailer name as well)
implement .tmgd or .nfo search and read
-idea would be to read the imdb ID # from existing .tmgd or .nfo
-and only if no present rely on name search
another idea for later versions, option to download trailer
write system checks for wrong trailers maybe match trailer name to file/folder name
and of coarse code clean up

KAD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
User avatar
KAD
Global Moderator
 
Posts: 4006
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby mad_ady » Thu Feb 02, 2012 10:48 pm

Congrats on your progress!
User avatar
mad_ady
Developer
 
Posts: 2996
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: my next crazy idea - trailers   

Postby jumbalaya » Thu Feb 02, 2012 11:56 pm

seriously, that's awesome! damn wd should've put a "trailer" button on the remote.
jumbalaya
OSD Themer
 
Posts: 251
Joined: Fri Apr 16, 2010 7:12 pm

Re: my next crazy idea - trailers   

Postby recliq » Fri Feb 03, 2012 1:32 am

what's this about?
Code: Select all
   var result1 = executeCmd("mount -o bind " + this.rootPath + "bin/play /usr/bin/play");
   var result2 = executeCmd("mount -o bind " + this.rootPath + "bin/upnp-cmd /usr/bin/upnp-cmd");
   var result3 = executeCmd("mount -o bind " + this.rootPath + "bin/upnp-meta /usr/bin/upnp-meta");


I think you just need to set the meta-info that you're handling a video file to circumvent the play in bg problem... so basically you just work around upnp-meta and build your own meta-info in your plugin with the info you gathered.
­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
recliq
WDLXTV Team
 
Posts: 5021
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: my next crazy idea - trailers   

Postby KAD » Fri Feb 03, 2012 8:34 am

those lines will be removed as they are not needed anymore

yeah, i'll have to build some meta

as above I've got a bunch of stuff to do still
I think reading imdbID from tgmd or nfo
will improve things a lot

also need to pull my actual WD remote to see what's on there
maybe there's a better button instead of stop

KAD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
User avatar
KAD
Global Moderator
 
Posts: 4006
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby KAD » Sun Feb 05, 2012 8:16 pm

this is coming right along, made a bunch of progress this weekend

as for meta data, eventually I should probably do something, but I found that currently the video does not get played in background, it gets played in foreground under the name Title 1

I'm able to read the imdb id from both tgmd and nfo files
so order of priority is tgmd, nfo, namesearch

I've got an icon on screen only when a trailer is found

but I do have some questions, I think the best method for an on screen icon would be similiar to mediamark how the icon is always placed on the folder that is selected
but I can't seem to see how to do that

the line in mediamark plugin looks very average with nothing special
Code: Select all
<image name="markIcon" image="@@markIcon" x="1070" y="450" w="40" h="40" scale="100" />


also thinking about mediamark (which I don't use) it also uses the stop button to mark files/folders
I guess this would make it rather incompatible with this plugin, unless somebody has idea's
only other button not in use on the page is eject, which I would like to be able to catch, but that doesn't seem to work

KAD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
User avatar
KAD
Global Moderator
 
Posts: 4006
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

PreviousNext

Return to WDTVExt discussion

Who is online

Users browsing this forum: No registered users and 1 guest