Skip to content

Instantly share code, notes, and snippets.

@milleniumbug
Last active August 23, 2023 16:53
Show Gist options
  • Save milleniumbug/2a0462d9524a9c05576dab3a93941f52 to your computer and use it in GitHub Desktop.
Save milleniumbug/2a0462d9524a9c05576dab3a93941f52 to your computer and use it in GitHub Desktop.
#!/bin/bash
# USAGE
# gettranscript.sh url [lang]
set -euo pipefail
URL="$1"
LANG="${2:-en}"
p=`mktemp`
dir=$(dirname "$p")
file=$(basename "$p")
cd "$dir"
yt-dlp \
-o "$file" \
--write-subs \
--write-auto-subs \
--sub-langs "$LANG" \
--skip-download \
"$URL" > /dev/stderr
ffmpeg -i "${file}.${LANG}.vtt" "${file}.${LANG}.srt"
cat "${file}.${LANG}.srt" | grep -v -- "-->" | grep -v -P '^[0-9]+' | grep -v -P -- '^\s*$' | dos2unix | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment