[WebDNA] YouTube Query Code Sample

This WebDNA talk-list message is from

2013


It keeps the original formatting.
numero = 110523
interpreted = N
texte = --047d7bf0c0465c0f0704e2c913a2 Content-Type: text/plain; charset=ISO-8859-1 Hi, here's how to connect to youTube to do a search and return xml results. These are not athenticated calls. Parameters: https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters#qsp Make the Call: [text]theSearchString=[url]"[/url]the+tragically+hip[url]"[/url][/text] [text]MyResult=[!] [/!][TCPConnect host=gdata.youtube.com][TCPSend skipheader=T]GET /feeds/api/videos?q=[theSearchString]&orderby=relevance&start-index=1&max-results=50&v=2 HTTP/1.0[UnURL]%0D%0A[/Unurl]Host: gdata.youtube.com [UnURL]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [xmlparse var=xml_var1][MyResult][/xmlparse] [xmlnodes ref=xml_var1&path=named:feed&name=openSearch:totalResults] Total Videos=[value]
[/xmlnodes] I got a result of:*Total Videos*=76214 from the "MyResult" variable you get the entire xml which can be deciphered here: https://developers.google.com/youtube/2.0/developers_guide_protocol_understanding_video_feeds#Understanding_Video_Entries Youtube limits the results to 1000 videos, but say you wanted to grab that information of all 1000 videos, you might start off with something like this. Note: you can do this with one call - but i have shown how to do it with two: I've limited this to pull 100 videos, but just change the 100 to 1000. From here, you dynamically generate field names and write to a database. There are different ways to parse the xml depending upon your needs. [showif [theSearchTotal]>100] [text]theSearchTotal=101[/text] [/showif] This code in action here: http://dev.tenplusone.com/youTubeEngine/testPull.html ----code starts here---- [text]showTracking=1[/text] [text]theSearchString=[url]"[/url]the+tragically+hip[url]"[/url][/text] [text]MyResult=[!] [/!][TCPConnect host=gdata.youtube.com][TCPSend skipheader=T]GET /feeds/api/videos?q=[theSearchString]&orderby=relevance&start-index=1&max-results=50&v=2 HTTP/1.0[UnURL]%0D%0A[/Unurl]Host: gdata.youtube.com [UnURL]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [xmlparse var=xml_var1][MyResult][/xmlparse] [xmlnodes ref=xml_var1&path=named:feed&name=openSearch:totalResults] Total Videos=[value]
[text]theSearchTotal=[value][/text] [/xmlnodes] [hideif [theSearchTotal]=0] [showif [theSearchTotal]>100] [text]theSearchTotal=101[/text] [/showif] [loop start=1&end=[theSearchTotal]&advance=50] *[index]
[text]MyResult2=[!] [/!][TCPConnect host=gdata.youtube.com][TCPSend skipheader=T]GET /feeds/api/videos?q=[theSearchString]&orderby=relevance&start-index=[index]&max-results=50&v=2 HTTP/1.0[UnURL]%0D%0A[/Unurl]Host: gdata.youtube.com [UnURL]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [xmlparse var=xml_var2][MyResult2][/xmlparse]
------------------------------------------------
[loop start=1&end=50] **[index]
[xmlnodes ref=xml_var2&path=named:feed/entry([index])] [showif [showTracking]=1] - [name]=[value]
[/showif] [xmlnodeattributes] [showif [showTracking]=1] -- [name]=[value]
[/showif] [/xmlnodeattributes] [xmlnodes] [showif [showTracking]=1] --- [name]=[value]
[/showif] [xmlnodeattributes] [showif [showTracking]=1] ---- [name]=[value]
[/showif] [/xmlnodeattributes] [xmlnodes] [/xmlnodes] [/xmlnodes] [/xmlnodes] ------------------------------------------------------------------------------------------------------------------------
[/loop] [/loop] --047d7bf0c0465c0f0704e2c913a2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Hi, here's how to co= nnect to youTube to do a search and return xml results. These are not athen= ticated calls.

Parameters:
https:/= /developers.google.com/youtube/2.0/developers_guide_protocol_api_query_para= meters#qsp

Make the Call:
[text]theSearchString=3D[url]"[/url]t= he+tragically+hip[url]"[/url][/text]

[text]MyResult=3D[!]
[/= !][TCPConnect host=3Dgdata.youtube.com= ][TCPSend skipheader=3DT]GET /feeds/api/videos?q=3D[theSearchString]&am= p;orderby=3Drelevance&start-index=3D1&max-results=3D50&v=3D2 HT= TP/1.0[UnURL]%0D%0A[/Unurl]Host: gdata= .youtube.com[UnURL]%0D%0A%0D%0A[/UnURL][/TCPSend]
[/TCPConnect][/text]

[xmlparse var=3Dxml_var1][MyResult][/xmlparse]<= br>
[xmlnodes ref=3Dxml_var1&path=3Dnamed:feed&name=3DopenSearch= :totalResults]
<b>Total Videos</b>=3D[value]<br />
= [/xmlnodes]

I got a result of:Total Videos=3D76214

<= div>from the "MyResult" variable you get the entire xml which can= be deciphered here: https://developers.google.com/youtube/2.0/developers_guide_protocol_un= derstanding_video_feeds#Understanding_Video_Entries


Youtube limits the results to 1000 videos, bu= t say you wanted to grab that information of all 1000 videos, you might sta= rt off with something like this.
Note: you can do this with = one call - but i have shown how to do it with two:

I've limited this to pull 100 videos, but just change th= e 100 to 1000.
From here, you dynamically generate field name= s and write to a database.
There are different ways to parse = the xml depending upon your needs.

[showif [theSearchTotal]>100]
=A0=A0=A0 [text]theSearc= hTotal=3D101[/text]
[/showif]

This code in action here:

http://dev.= tenplusone.com/youTubeEngine/testPull.html

----code starts here----


[text]showTracking=3D1[/text]
[text]theSearchString=3D[url]"[/url= ]the+tragically+hip[url]"[/url][/text]

[text]MyResult=3D[!]
= [/!][TCPConnect host=3Dgdata.youtube.c= om][TCPSend skipheader=3DT]GET /feeds/api/videos?q=3D[theSearchString]&= amp;orderby=3Drelevance&start-index=3D1&max-results=3D50&v=3D2 = HTTP/1.0[UnURL]%0D%0A[/Unurl]Host: gda= ta.youtube.com[UnURL]%0D%0A%0D%0A[/UnURL][/TCPSend]
[/TCPConnect][/text]

[xmlparse var=3Dxml_var1][MyResult][/xmlparse]<= br>

[xmlnodes ref=3Dxml_var1&path=3Dnamed:feed&name=3DopenSe= arch:totalResults]
<b>Total Videos</b>=3D[value]<br />=
[text]theSearchTotal=3D[value][/text]
[/xmlnodes]

[hideif [theSearchTotal]=3D0]

[showif [theSearch= Total]>100]
=A0=A0=A0 [text]theSearchTotal=3D101[/text]
[/showif]<= br>
[loop start=3D1&end=3D[theSearchTotal]&advance=3D50]
<= b>*[index]</b><br />

[text]MyResult2=3D[!]
[/!][TCPConnect host=3Dgdata.youtube.com][TCPSend skipheader=3DT]GET /feeds/api/= videos?q=3D[theSearchString]&orderby=3Drelevance&start-index=3D[ind= ex]&max-results=3D50&v=3D2 HTTP/1.0[UnURL]%0D%0A[/Unurl]Host: gdata.youtube.com[UnURL]%0D%0A%0D%0A[/U= nURL][/TCPSend]
[/TCPConnect][/text]

[xmlparse var=3Dxml_var2][MyResult2][/xmlparse]=

<br />------------------------------------------------<br = />

[loop start=3D1&end=3D50]
<b>**[index]</b>&= lt;br />

[xmlnodes ref=3Dxml_var2&path=3Dnamed:feed/entry([index])]

<= br>=A0=A0=A0 [showif [showTracking]=3D1]
=A0=A0=A0 - <b>[name]<= /b>=3D[value]<br />
=A0=A0=A0 [/showif]
[xmlnodeattributes]<= br>=A0=A0=A0 [showif [showTracking]=3D1]
=A0=A0=A0 -- <b>[name]</b>=3D[value]<br />
=A0=A0=A0 [= /showif]
[/xmlnodeattributes]

=A0=A0=A0 [xmlnodes]
=A0=A0=A0= =A0=A0=A0=A0 [showif [showTracking]=3D1]
=A0=A0=A0=A0=A0=A0=A0 --- <b= >[name]</b>=3D[value]<br />
=A0=A0=A0=A0=A0=A0=A0 [/showi= f]
=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0=A0=A0=A0=A0 [xmlnodeattributes]
=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 [showif [showTracking]=3D1]
=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 ---- <b>[name]</b>=3D[value]<br /><= br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 [/showif]
=A0=A0=A0=A0=A0=A0=A0 [/x= mlnodeattributes]
=A0=A0=A0 [xmlnodes]
=A0=A0=A0
[/xmlnodes]
[/xmlnodes]
[/xmlnodes]
<br />----= ---------------------------------------------------------------------------= -----------------------------------------<br /><br />
[/loop= ]
[/loop]


--047d7bf0c0465c0f0704e2c913a2-- Associated Messages, from the most recent to the oldest:

    
  1. [WebDNA] YouTube Query Code Sample (David Bastedo 2013)
--047d7bf0c0465c0f0704e2c913a2 Content-Type: text/plain; charset=ISO-8859-1 Hi, here's how to connect to youTube to do a search and return xml results. These are not athenticated calls. Parameters: https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters#qsp Make the Call: [text]theSearchString=[url]"[/url]the+tragically+hip[url]"[/url][/text] [text]MyResult=[!] [/!][TCPConnect host=gdata.youtube.com][TCPSend skipheader=T]GET /feeds/api/videos?q=[theSearchString]&orderby=relevance&start-index=1&max-results=50&v=2 HTTP/1.0[unurl]%0D%0A[/Unurl]Host: gdata.youtube.com [unurl]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [xmlparse var=xml_var1][MyResult][/xmlparse] [xmlnodes ref=xml_var1&path=named:feed&name=openSearch:totalResults] Total Videos=[value]
[/xmlnodes] I got a result of:*Total Videos*=76214 from the "MyResult" variable you get the entire xml which can be deciphered here: https://developers.google.com/youtube/2.0/developers_guide_protocol_understanding_video_feeds#Understanding_Video_Entries Youtube limits the results to 1000 videos, but say you wanted to grab that information of all 1000 videos, you might start off with something like this. Note: you can do this with one call - but i have shown how to do it with two: I've limited this to pull 100 videos, but just change the 100 to 1000. From here, you dynamically generate field names and write to a database. There are different ways to parse the xml depending upon your needs. [showif [theSearchTotal]>100] [text]theSearchTotal=101[/text] [/showif] This code in action here: http://dev.tenplusone.com/youTubeEngine/testPull.html ----code starts here---- [text]showTracking=1[/text] [text]theSearchString=[url]"[/url]the+tragically+hip[url]"[/url][/text] [text]MyResult=[!] [/!][TCPConnect host=gdata.youtube.com][TCPSend skipheader=T]GET /feeds/api/videos?q=[theSearchString]&orderby=relevance&start-index=1&max-results=50&v=2 HTTP/1.0[unurl]%0D%0A[/Unurl]Host: gdata.youtube.com [unurl]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [xmlparse var=xml_var1][MyResult][/xmlparse] [xmlnodes ref=xml_var1&path=named:feed&name=openSearch:totalResults] Total Videos=[value]
[text]theSearchTotal=[value][/text] [/xmlnodes] [hideif [theSearchTotal]=0] [showif [theSearchTotal]>100] [text]theSearchTotal=101[/text] [/showif] [loop start=1&end=[theSearchTotal]&advance=50] *[index]
[text]MyResult2=[!] [/!][TCPConnect host=gdata.youtube.com][TCPSend skipheader=T]GET /feeds/api/videos?q=[theSearchString]&orderby=relevance&start-index=[index]&max-results=50&v=2 HTTP/1.0[unurl]%0D%0A[/Unurl]Host: gdata.youtube.com [unurl]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [xmlparse var=xml_var2][MyResult2][/xmlparse]
------------------------------------------------
[loop start=1&end=50] **[index]
[xmlnodes ref=xml_var2&path=named:feed/entry([index])] [showif [showTracking]=1] - [name]=[value]
[/showif] [xmlnodeattributes] [showif [showTracking]=1] -- [name]=[value]
[/showif] [/xmlnodeattributes] [xmlnodes] [showif [showTracking]=1] --- [name]=[value]
[/showif] [xmlnodeattributes] [showif [showTracking]=1] ---- [name]=[value]
[/showif] [/xmlnodeattributes] [xmlnodes] [/xmlnodes] [/xmlnodes] [/xmlnodes] ------------------------------------------------------------------------------------------------------------------------
[/loop] [/loop] --047d7bf0c0465c0f0704e2c913a2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Hi, here's how to co= nnect to youTube to do a search and return xml results. These are not athen= ticated calls.

Parameters:
https:/= /developers.google.com/youtube/2.0/developers_guide_protocol_api_query_para= meters#qsp

Make the Call:
[text]theSearchString=3D[url]"[/url]t= he+tragically+hip[url]"[/url][/text]

[text]MyResult=3D[!]
[/= !][TCPConnect host=3Dgdata.youtube.com= ][TCPSend skipheader=3DT]GET /feeds/api/videos?q=3D[theSearchString]&am= p;orderby=3Drelevance&start-index=3D1&max-results=3D50&v=3D2 HT= TP/1.0[unurl]%0D%0A[/Unurl]Host: gdata= .youtube.com[unurl]%0D%0A%0D%0A[/UnURL][/TCPSend]
[/TCPConnect][/text]

[xmlparse var=3Dxml_var1][MyResult][/xmlparse]<= br>
[xmlnodes ref=3Dxml_var1&path=3Dnamed:feed&name=3DopenSearch= :totalResults]
<b>Total Videos</b>=3D[value]<br />
= [/xmlnodes]

I got a result of:Total Videos=3D76214

<= div>from the "MyResult" variable you get the entire xml which can= be deciphered here: https://developers.google.com/youtube/2.0/developers_guide_protocol_un= derstanding_video_feeds#Understanding_Video_Entries


Youtube limits the results to 1000 videos, bu= t say you wanted to grab that information of all 1000 videos, you might sta= rt off with something like this.
Note: you can do this with = one call - but i have shown how to do it with two:

I've limited this to pull 100 videos, but just change th= e 100 to 1000.
From here, you dynamically generate field name= s and write to a database.
There are different ways to parse = the xml depending upon your needs.

[showif [theSearchTotal]>100]
=A0=A0=A0 [text]theSearc= hTotal=3D101[/text]
[/showif]

This code in action here:

http://dev.= tenplusone.com/youTubeEngine/testPull.html

----code starts here----


[text]showTracking=3D1[/text]
[text]theSearchString=3D[url]"[/url= ]the+tragically+hip[url]"[/url][/text]

[text]MyResult=3D[!]
= [/!][TCPConnect host=3Dgdata.youtube.c= om][TCPSend skipheader=3DT]GET /feeds/api/videos?q=3D[theSearchString]&= amp;orderby=3Drelevance&start-index=3D1&max-results=3D50&v=3D2 = HTTP/1.0[unurl]%0D%0A[/Unurl]Host: gda= ta.youtube.com[unurl]%0D%0A%0D%0A[/UnURL][/TCPSend]
[/TCPConnect][/text]

[xmlparse var=3Dxml_var1][MyResult][/xmlparse]<= br>

[xmlnodes ref=3Dxml_var1&path=3Dnamed:feed&name=3DopenSe= arch:totalResults]
<b>Total Videos</b>=3D[value]<br />=
[text]theSearchTotal=3D[value][/text]
[/xmlnodes]

[hideif [theSearchTotal]=3D0]

[showif [theSearch= Total]>100]
=A0=A0=A0 [text]theSearchTotal=3D101[/text]
[/showif]<= br>
[loop start=3D1&end=3D[theSearchTotal]&advance=3D50]
<= b>*[index]</b><br />

[text]MyResult2=3D[!]
[/!][TCPConnect host=3Dgdata.youtube.com][TCPSend skipheader=3DT]GET /feeds/api/= videos?q=3D[theSearchString]&orderby=3Drelevance&start-index=3D[ind= ex]&max-results=3D50&v=3D2 HTTP/1.0[unurl]%0D%0A[/Unurl]Host: gdata.youtube.com[unurl]%0D%0A%0D%0A[/U= nURL][/TCPSend]
[/TCPConnect][/text]

[xmlparse var=3Dxml_var2][MyResult2][/xmlparse]=

<br />------------------------------------------------<br = />

[loop start=3D1&end=3D50]
<b>**[index]</b>&= lt;br />

[xmlnodes ref=3Dxml_var2&path=3Dnamed:feed/entry([index])]

<= br>=A0=A0=A0 [showif [showTracking]=3D1]
=A0=A0=A0 - <b>[name]<= /b>=3D[value]<br />
=A0=A0=A0 [/showif]
[xmlnodeattributes]<= br>=A0=A0=A0 [showif [showTracking]=3D1]
=A0=A0=A0 -- <b>[name]</b>=3D[value]<br />
=A0=A0=A0 [= /showif]
[/xmlnodeattributes]

=A0=A0=A0 [xmlnodes]
=A0=A0=A0= =A0=A0=A0=A0 [showif [showTracking]=3D1]
=A0=A0=A0=A0=A0=A0=A0 --- <b= >[name]</b>=3D[value]<br />
=A0=A0=A0=A0=A0=A0=A0 [/showi= f]
=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0=A0=A0=A0=A0 [xmlnodeattributes]
=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 [showif [showTracking]=3D1]
=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 ---- <b>[name]</b>=3D[value]<br /><= br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 [/showif]
=A0=A0=A0=A0=A0=A0=A0 [/x= mlnodeattributes]
=A0=A0=A0 [xmlnodes]
=A0=A0=A0
[/xmlnodes]
[/xmlnodes]
[/xmlnodes]
<br />----= ---------------------------------------------------------------------------= -----------------------------------------<br /><br />
[/loop= ]
[/loop]


--047d7bf0c0465c0f0704e2c913a2-- David Bastedo

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

WebDNA and Amazon S3 (2006) sendmail what is SIMS? (1999) Multiple cart additions (1997) [searh] or [shownext]problem (1998) multi-paragraph fields (1997) writefile on OSX (2004) Shopping Cart Problem (1998) WebCat Contest (1998) Sending mail (2003) Where is f2? (1997) $Quit, $CloseDatabase corrections (1997) Review comparison by PC Magazine: Open for On-line Business (1997) 2nd WebCatalog2 Feature Request (1996) [OrderFile] error (1999) [replaceChars] would be nice ... (1997) RE: [WebDNA] Encode cookies ONLY via "method=Base64" (2008) XML - USPS Lookups - UPS Lookups (2003) in conversions.db crashes unix webcat (1999) TEXT Variable (2003) 404 error -- but wc code executes... (2001)