Sign up here and you can log into the forum!

my next crazy idea - trailers

General WDTVExt forum

my next crazy idea - trailers   

Postby KAD » Fri Jan 27, 2012 11:31 am

anybody up for another teaching session,
@recliq, you've been great I've really learned a lot

so idea
when folder or file is selected
use item name to search for trailers online
if match is found onpagecreated to show a spiffy icon and trailer name
use on key press (probably stop button) to begin playback of trailer

thoughts?

this will be my first attempt to get anything from online with one of my scripts, so any examples advise is appreciated
I think this is doable, since all the individual elements have been done in some way,
it would be a matter of putting it all together in usable way

I also noticed in the weather plugin, that it simply calls a .php to do the work of getting info
it would be nice if we can simply call one of the existing UMSP plugins to do the work of getting the trailer
actually if calling an existing plugin works, it could even be user configuration to use their prefer trailer plugin
but maybe we'd need to modify the php

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: 4021
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby KAD » Sat Jan 28, 2012 10:26 am

ok, stuck

here's the bit I'm stuck on
Code: Select all
TrailerPlugin.prototype.getimdbid = function() {
   SearchName = this.SearchName;
   this.debug.Log("[ getimdbid ]" + SearchName, 2);
   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 = curl.responseText;
      var doc = content.toXML();
      var IMDBID = doc.tconst().toString();
      this.debug.Log("[ getimdbid ]" + IMDBID, 2);
   }
   return IMDBID;
}

I'm getting a valid responsetext , here's the line with the problem
Code: Select all
var IMDBID = doc.tconst().toString();

I need to extra to string the first instance of tconst

here's an example of part of response text
Code: Select all
{"@meta":{"serverTimeMs":40,"requestId":"0BNG50PSSXJZ2K6T1JF5"},"data":{"fields":["title","name"],"q":"The Dark Knight","results":[{"label":"Popular Titles","list":[{"tconst":"tt0468569","title":"The Dark Knight","type":"feature","year":"2


I need the variable IMDBID to be tt0468569

KAD

edit: digging it appears to be format called json, which from what I read is easy to handle in js but problably needs to be handled differently
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: 4021
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby KAD » Mon Jan 30, 2012 9:37 am

small steps :lol:

Code: Select all
var content = curl.responseText;
var contentlist = eval( "(" + content + ")" );
this.debug.Log("[ getimdbid ]" + contentlist, 2);


logs this
Code: Select all
[ getimdbid ] object object


now to figure out how to work with the objects

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: 4021
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby recliq » Mon Jan 30, 2012 10:21 am

I wouldn't use eval in this case! (eval is evil ;))
eval can do some very unexpected things and is a horror security wise (if a third person is able to push JSON to your script)...
EDIT: It seems you have to use eval since the javascript engine in WDTVExt doesn't support the JSON object :(
It's supported in JavaScript-C 1.8.1 and higher but WDTVExt is based on JavaScript-C 1.8.0.

Here are some nice links on handling JSON in javascript:
http://www.json.org/js.html
http://www.hunlock.com/blogs/Mastering_JSON_%28_JavaScript_Object_Notation_%29

Once you get an object from JSON string (which you already did) you access the object much like you would access an XML object in js.
So you should be able to access values from the JSON string like this:
Code: Select all
var test = contentlist.@meta.serverTimeMs // should set test to 40

I'm not sure with the @meta (if it's allowed to write it like this) otherwise you can try this
[code]var test = contentlist["@meta"].serverTimeMs
­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: 5036
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: my next crazy idea - trailers   

Postby KAD » Mon Jan 30, 2012 10:41 am

yeah I read about the security issues this weekend, but I also couldn't determine if our version of javascript could handle something like JSON.parse or jQuery, or even ajax
any chance on updating the javascript engine in WDLXTV 5.1.5?

as always, great tips and pointers on how to do this, learning a ton here, and having fun doing
can't wait to try that test tonight

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: 4021
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby recliq » Mon Jan 30, 2012 11:56 am

no, it's build into WDTVExt libext.so
­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: 5036
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: my next crazy idea - trailers   

Postby KAD » Tue Jan 31, 2012 12:37 pm

@recliq, thanks for your help.

I finally last night was able to correctly parse that json response, what a pain in the ***

contentlist.data.results had to be loaded as an array before I could access any data inside it
it also had a second nested array as well
but I'm now well on my way to having a functional plugin

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: 4021
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby KAD » Wed Feb 01, 2012 12:49 pm

@recliq you must be doing something right, just look at how far I've come
I'm so close to having a working beta

currently what I'm able to do, dynamically find url for trailers
url's look like this
http://www.imdb.com/video/imdb/vi3444113945/html5?format=240p (playable on PC browser)

a URL in this format is obviously not passable to upnp-cmd on WD because it does not end with .avi or other extension

question - if I curl this url, will it produce an http address that can be played back with upnp-cmd ??
(I was too tired to try last night, will try when home)

or is there a better way to play this url

looking at some existing plugins, I see links being passed like this
127.0.0.1/tmp/xyz.php

do you think this will be required for playback
or should I somehow pass this to UMSP server

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: 4021
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: my next crazy idea - trailers   

Postby recliq » Wed Feb 01, 2012 2:59 pm

hint: If you sniff around in the source of that page you will find something like this
Code: Select all
video-http.media-imdb.com/MV5BMTYzODY1MTAxOF5BMTFeQW1wNF5BbWU3MDEyNTkyMzM@.mp4?Expires=1328169343&Signature=O0PE79bFTQjbtCVBmwvFL49AiOKQZEiPWJiTUDfQISzAKsiM1ULiZDRWvgQsSAjhHoDj6e8pns1QLgrLqKfR~PooydK4F0a2b-aEcMGCy3KRc6KjYdjSPsvmEgB7-N1AgcH3YcZ3I~fVlPLGWElBMqsOCzs2cIWGXd0LTJGTWuM_&Key-Pair-Id=APKAILW5I44IHKUN2DYA&hint=flv
­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: 5036
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: my next crazy idea - trailers   

Postby KAD » Wed Feb 01, 2012 3:09 pm

that's sort of what I was hoping for :D
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: 4021
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Next

Return to WDTVExt discussion

Who is online

Users browsing this forum: No registered users and 0 guests