Created
December 1, 2025 19:01
-
-
Save stepney141/f91907a5bf54b68dea9e9a2d83b3c4eb to your computer and use it in GitHub Desktop.
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 | |
| playlist="https://www.youtube.com/playlist?list=THIS_IS_AN_EXAMPLE" | |
| mkdir -p './logs/' | |
| get-failed () { | |
| local all="$1" | |
| local success="$2" | |
| comm -23 <(sort -u "$all") <(sort -u "$success") | |
| } | |
| ytdlp() { | |
| LOCAL_DIR="$(pwd)" | |
| PARENT_DIR="$(dirname "$LOCAL_DIR")" | |
| docker run --rm -u "$(id -u)":"$(id -g)" --network host \ | |
| -v "$LOCAL_DIR":/work -v "$PARENT_DIR/cookies":/cookies -w /work \ | |
| jauderho/yt-dlp:latest "$@" | |
| } | |
| download() { | |
| local url="$1" | |
| # プレイリスト名を取得 | |
| pl_name=$(ytdlp --skip-download --print "%(playlist_title)s" "$url" 2>/dev/null | head -n1) | |
| safe_name=$(echo "$pl_name" | tr '/\\:*?"<>|' '_') | |
| ytdlp \ | |
| --remote-components ejs:npm \ | |
| --embed-metadata --no-embed-info-json --embed-thumbnail --write-info-json \ | |
| --parse-metadata "video::(?P<formats>)" --parse-metadata "video::(?P<automatic_captions>)" --parse-metadata "video::(?P<heatmap>)" \ | |
| --min-sleep-interval 30 --max-sleep-interval 40 \ | |
| --ignore-errors --merge-output-format mp4 \ | |
| --print-to-file after_move:original_url "${safe_name}-success.txt" \ | |
| --download-archive ./archive.txt \ | |
| --cookies /cookies/www.youtube.com_cookies.txt \ | |
| -o "%(playlist_title)s/%(title)s.%(ext)s" \ | |
| "$url" 2>&1 | tee -a ./logs/"$(date +%Y%m%d-%H%M%S)".log | |
| } | |
| get-urls() { | |
| ytdlp --flat-playlist --get-url "$@" | |
| } | |
| get-urls "$playlist" > ./playlist-all-urls.txt | |
| download "$playlist" | |
| get-failed ./playlist-all-urls.txt ./playlist-success.txt > ./playlist-failed-urls.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment