Created
November 18, 2023 04:50
-
-
Save apeckham/3f48a97fe5fceb3d4d9b2cce55b996d3 to your computer and use it in GitHub Desktop.
download subs from a channel
This file contains hidden or 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 | |
# yt-dlp --skip-download --write-auto-subs --convert-subs srt "https://www.youtube.com/@CHANNEL" | |
# run this script | |
# for f in out/*.txt; do echo "$f"; cat "$f"; echo -e "\n\n\n"; done | split -l 100000 | |
output_directory="out" | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 file1.srt file2.srt ..." | |
exit 1 | |
fi | |
mkdir -p "$output_directory" | |
for input_file in "$@"; do | |
if [[ $input_file == *.srt ]]; then | |
filename=$(basename "$input_file" .srt) | |
output_file="$output_directory/$filename.txt" | |
cat "$input_file" | tr -d '\r' | grep -v '^[0-9]*$' | grep -v -- '-->' | grep -v '^[[:space:]]*$' | uniq > "$output_file" | |
else | |
echo "Skipping non-SRT file: $input_file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment