I did something similar for myself a while back, to put the transcript in a text file. It's a five line bash script that uses youtube-dl to get the closed captions and cleans up the formatting.
#!/bin/bash
link="$1"
fn="captions"
youtube-dl --output $fn.%(ext)s --write-auto-sub --skip-download $link
sed '/-->/d' $fn.en.vtt | sed '/<c>/d' | sed '/^[[:space:]]\*$/d' | uniq > $fn.txt