How to extract closed caption transcript from YouTube video?

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

–write-sub
Write subtitle file

–write-auto-sub
Write automatically generated subtitle file (YouTube only)

–all-subs
Download all the available subtitles of the video

–list-subs
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