cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Craige_Hales
Super User
YouTube API

Extracting a section of a webpagehas apparently got some stale info; the web scraping from Feb 2020 no longer seems to work in Jul 2021. Well, that's expected because there is no reason why YouTube can't change the HTML that formats the web page. @LNitz prompted me to take another look and show how to use a more official API to get the data and how to store that data into a data table.

The comments in the JSL will point you to a page where you can get an API key. Google/YouTube use the key to restrict the number of requests you can make. Building this code apparently used about 500/10,000 of my daily quota. I've run it a lot. https://console.cloud.google.com/apis/dashboard .

The original question was about getting descriptions of YouTube videos into a data table. The answer downloaded the (~500Kbyte) web page HTML and pattern matched for keywords...that seem to have changed, so the matching no longer works. The API should be more robust. It returns JSON data, which is way easier to parse than HTML. Smaller too. The problem now becomes reading API docs to figure out how it works. Fortunately most questions can be googled.

Video links, descriptions, thumbnails.Video links, descriptions, thumbnails.

JSL, attached, also adds the blue links to the ID column.

The JSL uses several APIs:

  • channels - find my channel and my channel's upload list ID.
  • playlistItems - the upload list is a playlist. Get the video IDs from that play list.
  • videos - get information about a video using its ID.

YouTube video IDs are the cryptic blue link values in the picture. The JSL is a bit silly because the information being stored in the data table was available from the playlistitems, but you might be starting with video IDs that are not in a play list.

There's a lot more to the API; pretty much anything you can do from the web interface (upload, delete, etc) can be done through the API.

 

Edit: @bryan_boone  posted more info in Integrating Google Drive with JMP using HTTP Request  -- related to the keys you can get from the google console.

Last Modified: Sep 18, 2022 9:35 PM
Comments