#! /bin/sh # This script downloads YouTube videos for archival in a high-compatibility # format with embedded metadata using https://github.com/yt-dlp/yt-dlp/. set -eu log_url=0 max_height=1080 while :; do case "$1" in -l | --log) log_url=1 shift ;; -m | --max-height) max_height=$2 shift 2 ;; *) break ;; esac done yt-dlp \ --add-metadata \ --embed-chapters \ --embed-subs \ --embed-thumbnail \ --format "bestvideo[vcodec*=avc1][height<=$max_height]+bestaudio[ext=m4a]" \ --sub-langs en \ --write-auto-subs \ "$@" \ ; if [ "$log_url" -eq 1 ]; then for url in "$@"; do printf '%s\n' "$url" >> urls.txt done fi