[WebDNA] API - YouTube

This WebDNA talk-list message is from

2011


It keeps the original formatting.
numero = 106439
interpreted = N
texte = So another unauthenticated call - but this is really powerful - nonetheless= . Again, it's really about what you want to do with data once you have it. This example pulls all the data down about every video on a YouTube Channel. . . . so, say you want to compare videos from two competitors over time - or keep track of what is happenig to your own videos. This will pull down all the stats. Hook it up to a trigger at the same time every day , and you have a consistent time line of data. This can be used will all sorts of things. I used this to pull down information about videos posted by every maker car manufacturer as a test case. So all you need is a list of channels and then to loop through the results. The info comes down in sets of 50 results, so you need to first get the number of videos, to set the number of times you have to loop. I left the entire thing intact here for you. This is again, the basic structure for all YouTube calls. So you need to change very little to get the information on say one video . . . d. [text]channelName=3D[YouTubeChannel][/text] [text]MyTestVariable=3D[!] [/!][TCPConnect host=3Dgdata.youtube.com][TCPSend skipheader=3DT]GET /feeds/api/users/[channelName]/uploads?start-index=3D1&max-results=3D50&v= =3D2 HTTP/1.0[UnURL]%0D%0A[/Unurl]Host: gdata.youtube.com[UnURL]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [!]------------[/!] [xmlparse var=3Dxml_var2][MyTestVariable][/xmlparse] MyTestVariable: [MyTestVariable]
[!]---------------------------[/!] [xmlnodes ref=3Dxml_var2&path=3Dnamed:feed&name=3DopenSearch:totalResults] [text]TotalVideos=3D[value][/text] [/xmlnodes] TotalVideos: [TotalVideos]
channelName: [channelName]
channelType: [LOOKUP db=3Ddatabases/channelType.db&value=3D[channelName]&lookInField=3DchannelNa= me&returnField=3DchannelType]
[!]---------------------[/!] [loop start=3D1&end=3D[TotalVideos]&advance=3D50] [text]MyTestVariable=3D[!] [/!][TCPConnect host=3Dgdata.youtube.com][TCPSend skipheader=3DT]GET /feeds/api/users/[channelName]/uploads?start-index=3D[index]&max-results=3D= 50&v=3D2 HTTP/1.0[UnURL]%0D%0A[/Unurl]Host: gdata.youtube.com[UnURL]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [xmlparse var=3Dxml_var1][MyTestVariable][/xmlparse] [loop start=3D1&end=3D50] [xmlnode ref=3Dxml_var1&path=3Dnamed:feed/entry([index])/id] [listwords words=3D[value]&delimiters=3D:] [showif [index]=3D4] [text]theVideoID=3D[word][/text] [/showif] [/listwords] [/xmlnode] [!]------------- TheVideoID=3D[theVideoID]

------------[/!] [addfields db=3Ddatabases/videoData.db]dateNum=3D&channelName=3D&timeNum=3D= [/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_Num]&eqtimeNumdatarq=3D[time_num]&append=3Dt]videoID=3D[th= eVideoID]&dateNum=3D[date_num]&channelName=3D[channelName]&channelType=3D[c= hannelType]&theCategory=3D2&timeNum=3D[time_num][/replace] [!]----------------------------------------------
--------------------------------
&eqvideoIDdata=3D[theVideoID]&eqdateNumdatarq=3D[date_num]&append=3Dt]video= ID=3D[theVideoID]&dateNum=3D[date_num]&channelName=3D[channelName]
--------------------------------
----------------------------------------------[/!] [addfields db=3Ddatabases/videoData.db]theCategory=3D[/addfields] [xmlnodes ref=3Dxml_var1&path=3Dnamed:feed/entry([index])] [addfields db=3Ddatabases/videoData.db][name]=3D[/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_num]&eqtimeNumdatarq=3D[time_num]&append=3Dt][name]=3D[url= ][value][/url]&dateNum=3D[date_num]&channelName=3D[channelName]&channelType= =3D[channelType]&theCategory=3D2&timeNum=3D[time_num][/replace] [text]firstNode=3D[name][/text] [!]------------- - [name]=3D[value]
------------[/!] [xmlnodeattributes] [!]------------- -- [name]=3D[value]
------------[/!] [addfields db=3Ddatabases/videoData.db][firstNode]_[name]=3D[/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_num]&eqtimeNumdatarq=3D[time_num]&append=3Dt][firstNode]_[= name]=3D[url][value][/url]&timeNum=3D[time_num]&dateNum=3D[date_num]&channe= lName=3D[channelName]&channelType=3D[channelType]&theCategory=3D2[/replace] [/xmlnodeattributes] [xmlnodes] [!]------------- --- [name]=3D[value]
------------[/!] [text]firstNodeB=3D[name][/text] [addfields db=3Ddatabases/videoData.db][name]=3D[/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_num]&eqtimeNumdatarq=3D[time_num]&append=3Dt][name]=3D[url= ][value][/url]&dateNum=3D[date_num]&channelName=3D[channelName]&channelType= =3D[channelType]&theCategory=3D2&timeNum=3D[time_num][/replace] [xmlnodeattributes] [!]------------- ---- [name]=3D[value]
------------[/!] [addfields db=3Ddatabases/videoData.db][firstNodeB]_[name]=3D[/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_num]&eqtimeNumdatarq=3D[time_num]&append=3Dt][firstNodeB]_= [name]=3D[url][value][/url]&dateNum=3D[date_num]&channelName=3D[channelName= ]&channelType=3D[channelType]&theCategory=3D2&timeNum=3D[time_num][/replace= ] [/xmlnodeattributes] [xmlnodes] [/xmlnodes] [/xmlnodes] [/xmlnodes] [/loop] [/loop] Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] API - YouTube ("Psi Prime Inc, Matthew A Perosi " 2011)
  2. [WebDNA] API - YouTube (David Bastedo 2011)
So another unauthenticated call - but this is really powerful - nonetheless= . Again, it's really about what you want to do with data once you have it. This example pulls all the data down about every video on a YouTube Channel. . . . so, say you want to compare videos from two competitors over time - or keep track of what is happenig to your own videos. This will pull down all the stats. Hook it up to a trigger at the same time every day , and you have a consistent time line of data. This can be used will all sorts of things. I used this to pull down information about videos posted by every maker car manufacturer as a test case. So all you need is a list of channels and then to loop through the results. The info comes down in sets of 50 results, so you need to first get the number of videos, to set the number of times you have to loop. I left the entire thing intact here for you. This is again, the basic structure for all YouTube calls. So you need to change very little to get the information on say one video . . . d. [text]channelName=3D[YouTubeChannel][/text] [text]MyTestVariable=3D[!] [/!][TCPConnect host=3Dgdata.youtube.com][TCPSend skipheader=3DT]GET /feeds/api/users/[channelName]/uploads?start-index=3D1&max-results=3D50&v= =3D2 HTTP/1.0[unurl]%0D%0A[/Unurl]Host: gdata.youtube.com[unurl]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [!]------------[/!] [xmlparse var=3Dxml_var2][MyTestVariable][/xmlparse] MyTestVariable: [MyTestVariable]
[!]---------------------------[/!] [xmlnodes ref=3Dxml_var2&path=3Dnamed:feed&name=3DopenSearch:totalResults] [text]TotalVideos=3D[value][/text] [/xmlnodes] TotalVideos: [TotalVideos]
channelName: [channelName]
channelType: [LOOKUP db=3Ddatabases/channelType.db&value=3D[channelName]&lookInField=3DchannelNa= me&returnField=3DchannelType]
[!]---------------------[/!] [loop start=3D1&end=3D[TotalVideos]&advance=3D50] [text]MyTestVariable=3D[!] [/!][TCPConnect host=3Dgdata.youtube.com][TCPSend skipheader=3DT]GET /feeds/api/users/[channelName]/uploads?start-index=3D[index]&max-results=3D= 50&v=3D2 HTTP/1.0[unurl]%0D%0A[/Unurl]Host: gdata.youtube.com[unurl]%0D%0A%0D%0A[/UnURL][/TCPSend] [/TCPConnect][/text] [xmlparse var=3Dxml_var1][MyTestVariable][/xmlparse] [loop start=3D1&end=3D50] [xmlnode ref=3Dxml_var1&path=3Dnamed:feed/entry([index])/id] [listwords words=3D[value]&delimiters=3D:] [showif [index]=3D4] [text]theVideoID=3D[word][/text] [/showif] [/listwords] [/xmlnode] [!]------------- TheVideoID=3D[theVideoID]

------------[/!] [addfields db=3Ddatabases/videoData.db]dateNum=3D&channelName=3D&timeNum=3D= [/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_Num]&eqtimeNumdatarq=3D[time_num]&append=3Dt]videoID=3D[th= eVideoID]&dateNum=3D[date_num]&channelName=3D[channelName]&channelType=3D[c= hannelType]&theCategory=3D2&timeNum=3D[time_num][/replace] [!]----------------------------------------------
--------------------------------
&eqvideoIDdata=3D[theVideoID]&eqdateNumdatarq=3D[date_num]&append=3Dt]video= ID=3D[theVideoID]&dateNum=3D[date_num]&channelName=3D[channelName]
--------------------------------
----------------------------------------------[/!] [addfields db=3Ddatabases/videoData.db]theCategory=3D[/addfields] [xmlnodes ref=3Dxml_var1&path=3Dnamed:feed/entry([index])] [addfields db=3Ddatabases/videoData.db][name]=3D[/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_num]&eqtimeNumdatarq=3D[time_num]&append=3Dt][name]=3D[url= ][value][/url]&dateNum=3D[date_num]&channelName=3D[channelName]&channelType= =3D[channelType]&theCategory=3D2&timeNum=3D[time_num][/replace] [text]firstNode=3D[name][/text] [!]------------- - [name]=3D[value]
------------[/!] [xmlnodeattributes] [!]------------- -- [name]=3D[value]
------------[/!] [addfields db=3Ddatabases/videoData.db][firstNode]_[name]=3D[/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_num]&eqtimeNumdatarq=3D[time_num]&append=3Dt][firstNode]_[= name]=3D[url][value][/url]&timeNum=3D[time_num]&dateNum=3D[date_num]&channe= lName=3D[channelName]&channelType=3D[channelType]&theCategory=3D2[/replace] [/xmlnodeattributes] [xmlnodes] [!]------------- --- [name]=3D[value]
------------[/!] [text]firstNodeB=3D[name][/text] [addfields db=3Ddatabases/videoData.db][name]=3D[/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_num]&eqtimeNumdatarq=3D[time_num]&append=3Dt][name]=3D[url= ][value][/url]&dateNum=3D[date_num]&channelName=3D[channelName]&channelType= =3D[channelType]&theCategory=3D2&timeNum=3D[time_num][/replace] [xmlnodeattributes] [!]------------- ---- [name]=3D[value]
------------[/!] [addfields db=3Ddatabases/videoData.db][firstNodeB]_[name]=3D[/addfields] [replace db=3Ddatabases/videoData.db&eqvideoIDdatarq=3D[theVideoID]&eqdateN= umdatarq=3D[date_num]&eqtimeNumdatarq=3D[time_num]&append=3Dt][firstNodeB]_= [name]=3D[url][value][/url]&dateNum=3D[date_num]&channelName=3D[channelName= ]&channelType=3D[channelType]&theCategory=3D2&timeNum=3D[time_num][/replace= ] [/xmlnodeattributes] [xmlnodes] [/xmlnodes] [/xmlnodes] [/xmlnodes] [/loop] [/loop] 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:

Can't use old cart file (was One more try) (1997) off topic fetch vs PCS photomaster (1997) Problems passing [SKU] with $Replace in 2.0 (1997) form validator issue (2005) Using WebCat for product info requests (1997) Protect (1997) Recursion & WebDNA (1999) Sorting error (1997) WC Database Format (1997) UPDATEDONE question ... (1998) Sorting Numbers (1997) Online magazine- monthly updates and such (1999) [WebDNA] WebDNA & MS SQL (2013) PCS Frames (1997) Progress !! WAS: Trouble with formula.db (1997) Date search - yes or no (1997) A question on sub-categories (1997) Text data with spaces in them... (1997) Whats up with emailer? (1998) Search minus first found (1999)