Last active
September 10, 2023 04:18
-
-
Save szero/ed7f656ae8017526dfa00ab47351c409 to your computer and use it in GitHub Desktop.
Download a South Park episode from southparkstudios.com
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
#!/usr/bin/env bash | |
if [[ $# != 1 ]]; then | |
echo "Usage: get_south_park <page link>" | |
exit 0 | |
fi | |
TD="$(mktemp -d)" | |
clear_on_exit() { | |
rm -rf "$TD" | |
exit | |
} | |
trap clear_on_exit SIGINT SIGTERM SIGHUP EXIT | |
FLIST="$TD/list.txt" | |
title="$(youtube-dl --no-warnings --dump-single-json "$1" | grep -oP "(?<=\"playlist_title\":\s\").+?(?=\")" | head -n1)" | |
title="$(echo "$title" | tr " " "_")" | |
youtube-dl -f mp4 -o "$TD/%(autonumber)s.%(ext)s" "$1" | |
for f in "$TD"/000*.mp4 ; do | |
echo "file '$f'" >> "$FLIST" | |
done | |
SE=$(echo "$1" | grep -ioP '\-season\-\K[\d]{1,2}') | |
EP=$(echo "$1" | grep -ioP '\-ep\-\K[\d]{1,2}') | |
if [[ "${#EP}" == 1 ]]; then | |
EP="0$EP" | |
fi | |
NAME="South_Park.SE${SE}.EP${EP}.$title.mp4" | |
ffmpeg -hide_banner -f concat -safe 0 -i "$FLIST" -c copy -f mp4 "$TD/$NAME.temp" | |
ffmpeg -hide_banner -i "$TD/$NAME.temp" -c copy -movflags +faststart -f mp4 "$TD/$NAME" | |
mv "$TD/$NAME" "$(pwd)" | |
Updated the script to work with southparkstudios.com site. Also I'm using grep with -P arg now. MacOS may not like it (not sure) since as I recall Tim Cook ships non-PCRE compliant version of it. Probably fixable with homebrew.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dependencies:
Use the script with the url of episode that can stream in your browser, for example:
./get_southpark "https://www.southparkstudios.com/episodes/yy0vjs/south-park-the-pandemic-special-season-24-ep-1"