Shoutbox

[?] Playing with the Google Data (YouTube) API... - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] Playing with the Google Data (YouTube) API... (/showthread.php?tid=87617)

[?] Playing with the Google Data (YouTube) API... by roflmao456 on 12-06-2008 at 03:16 AM

Could anyone help me with this? I seem to be getting "Expected ';'" errors..

JScript code:
function YouTube_Search(Keyword,sIndex,Length,option){
    var result={keyword:Keyword,VideoInfo:[],start:sIndex,end:0,total:-1};
    result.start=(((result.start-1)/10)*20)+1;
    var api=eval(GetContents("http://gdata.youtube.com/feeds/api/videos?q="+Keyword+"&alt=json"));    result.total=parseInt(api.openSearch$totalResults.$t);
    while(1){
        for(i in api.entry)result.VideoInfo.push({URL:"http://www.youtube.com/watch?v="+api.entry[i].id.$t.substr(api.entry[i].id.$t.lastIndexOf("/")+1),ThumbnailURL:api.entry[i].media$thumbnail[0].url,Title:api.entry[i].media$title.$t,Description:api.entry[i].media$description.$t,ViewCount:parseInt(api.entry[i].yt$statistics.viewCount),LengthSeconds:parseInt(api.entry[i].yt$duration.seconds),SaveFilename:ToFilename(api.entry[i].media$title.$t),attr:7
});
        if(result.start+(result.VideoInfo.length-1)==result.total)break;
        }
    result.VideoInfo.length?result.end=result.start+(result.VideoInfo.length-1):result.total=0;
    if(result.VideoInfo.length!=20&&result.start!=1)result.total=result.end;
    return result;
}

underlined: Expected ";" error

GetContents is a XMLHTTP GET request and returns the responseText.

Basically i'm just searching youtube =P

oh and sorry for ruining the layout.
RE: [?] Playing with the Google Data (YouTube) API... by NanaFreak on 12-06-2008 at 03:41 AM

well seeing as your doing and eval, wouldnt you need a ; inside the eval'ed code? as it has to comply with the js standards? =\


RE: [?] Playing with the Google Data (YouTube) API... by roflmao456 on 12-06-2008 at 04:37 AM

quote:
Originally posted by NanaFreak
well seeing as your doing and eval, wouldnt you need a ; inside the eval'ed code? as it has to comply with the js standards? =\
i already tried putting a ;..

no difference :(
RE: [?] Playing with the Google Data (YouTube) API... by Matti on 12-06-2008 at 09:49 AM

I'm just guessing here, but maybe you should first store the GetContents result in a variable and check if it was successful to avoid unwanted results. When I looked at the resulting JSON, it looks like it's missing a semi-colon at the end, so you might want to add that.

Are you sure that GetContents returns the response properly? In order to get that working, it has to be done synchronously (xmlHttp.async = false) otherwise you can't retrieve the response.


RE: [?] Playing with the Google Data (YouTube) API... by roflmao456 on 12-06-2008 at 08:45 PM

JScript code:
function GetContents(url){
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",url,0);
xmlhttp.send();
return xmlhttp.responseText;
}


it works perfectly.
RE: [?] Playing with the Google Data (YouTube) API... by felipEx on 12-07-2008 at 05:04 PM

JScript code:
    var api=eval(GetContents("http://gdata.youtube.com/feeds/api/videos?q="+Keyword+"&alt=json"));


JScript code:
var results = eval( '(' + xmlhttp.responseText + ')' );
 
Debug.Trace(results.feed["openSearch$totalResults"]["$t"]);
// Debug.Trace(results.feed.entry[0]["media$group"]["media$title"]["$t"]);


See also: Using JSON with Google Data APIs / Requesting and using JSON feeds ;)
RE: [?] Playing with the Google Data (YouTube) API... by roflmao456 on 12-08-2008 at 01:23 AM

yay for felipe (Y):P
figured it out from there :)