1

I'd like to take a set of YT videos and, from the metadata, determine:

  1. how many of them have closed captioning
  2. whether it's autogenerated closed captioning
  3. what language the captions are in

I know there's contentDetails.caption, but in the set I'm looking at, I get "false" for all videos while several of them do in fact have autogenerated closed captioning. This leads me to wonder the best way to answer these questions.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
rzmg
  • 21
  • 1

1 Answers1

0

You need to Captions: list API from youtube's v3 Data API.

When passing video ID with "id" and "snippet" parts, you'll get a list of available subtitles for the video and which indicates the subtitle type and language among with many other useful information. The number of entries in the list indicates the number of subtitles it has.

If you have multiple videos to check, run them through a loop and get their subtitle metadata one by one. Test it yourself!

curl \
  'https://youtube.googleapis.com/youtube/v3/captions?part=id&part=snippet&videoId=[YourVideoId]&key=[YOUR_API_KEY]' \
  --header 'Accept: application/json' \
  --compressed
Mohsen
  • 427
  • 4
  • 20
  • Thanks for this response. This is, for the moment, hypothetical. I don't have an api key on hand at the moment, and it's likely someone else will be doing the query. What I'm trying to learn is what's possible. So by doing what you've suggested, I'll be able to see all of the captions, including autogenerated and manually input, and the ability to tell the difference between them (not just between languages)? Presumably a video with no available captions won't return any values? Thanks again. – rzmg Jan 24 '22 at 04:23
  • @rzmg 1- You can go to google developer console and get API key for free. 2- Yes, you'll get the languages and subtitle type (auto generated or manual) plus some more information which might come handy. 3- It will return an empty array, means there's no any subs. I recommend you to explore Youtube Data API V3 documentation and playground and see what's there. – Mohsen Jan 24 '22 at 10:21