How to extract closed caption transcript from YouTube video?

youtube-dl –skip-download –write-auto-sub $youtube_url

Write subtitle file

Write automatically generated subtitle file (YouTube only)

Download all the available subtitles of the video

List all available subtitles for the video

–sub-format FORMAT
Subtitle format, accepts formats preference, for example: “srt” or “ass/srt/best”

–sub-lang LANGS
Languages of the subtitles to download (optional) separated by commas, use –list-sub