What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [?] Playing with the Google Data (YouTube) API...

[?] Playing with the Google Data (YouTube) API...
Author: Message:
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. [?] Playing with the Google Data (YouTube) API...
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.

This post was edited on 12-06-2008 at 03:17 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
12-06-2008 03:16 AM
Profile PM Web Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: [?] Playing with the Google Data (YouTube) API...
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? =\
12-06-2008 03:41 AM
Profile PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: [?] Playing with the Google Data (YouTube) API...
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 :(
[quote]
Ultimatess6
: What a noob mod
12-06-2008 04:37 AM
Profile PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [?] Playing with the Google Data (YouTube) API...
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.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-06-2008 09:49 AM
Profile E-Mail PM Web Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: [?] Playing with the Google Data (YouTube) API...
jscript code:
function GetContents(url){
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",url,0);
xmlhttp.send();
return xmlhttp.responseText;
}

it works perfectly.
[quote]
Ultimatess6
: What a noob mod
12-06-2008 08:45 PM
Profile PM Web Find Quote Report
felipEx
Scripting Contest Winner
***


Posts: 378
Reputation: 24
35 / Male / Flag
Joined: Jun 2006
RE: [?] Playing with the Google Data (YouTube) API...
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 ;)
12-07-2008 05:04 PM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: [?] Playing with the Google Data (YouTube) API...
yay for felipe (Y):P
figured it out from there :)
[quote]
Ultimatess6
: What a noob mod
12-08-2008 01:23 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On