Skip to content

Instantly share code, notes, and snippets.

@neuthral
Created October 8, 2022 09:02
Show Gist options
  • Save neuthral/d86c4825e03b21e1789977832684f532 to your computer and use it in GitHub Desktop.
Save neuthral/d86c4825e03b21e1789977832684f532 to your computer and use it in GitHub Desktop.
youtube get video subtitles and cleant up the file for readability
youtube-get-subs() {
echo "getting filenames..."
filename=$(youtube-dl --simulate --get-title $1)-$(youtube-dl --simulate --get-id $1)
echo "Downloading video data"
youtube-dl --continue --write-auto-sub --sub-format vtt --sub-lang en --write-thumbnail --write-description --skip-download $1
echo $filename
echo "Removing --> time stuff"
sed -i '/-->/d' $filename.en.vtt
echo "Removing empty lines"
grep "\S" $filename.en.vtt > $filename.txt
echo "Deleting old subtitle file"
rm $filename.en.vtt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment