Last active
August 23, 2023 16:53
-
-
Save milleniumbug/2a0462d9524a9c05576dab3a93941f52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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