#!/usr/bin/env bash # exit if a command fails set -o errexit # exit if required variables are not set set -o nounset # check for dependencies script_commands="AtomicParsley attr ffmpeg ffprobe yt-dlp" missing_counter=0 for needed_command in ${script_commands}; do if ! hash "${needed_command}" >/dev/null 2>&1; then printf "Command not found in PATH: %s\n" "${needed_command}" >&2 ((missing_counter++)) fi done if ((missing_counter > 0)); then printf "Minimum %d commands are missing in PATH, aborting.\n" "${missing_counter}" >&2 exit 1 fi # make sure the correct number of arguments are passed; if not, output syntax and exit if [ "$#" -ne 2 ]; then echo -e "\nUsage: $0 \n" exit 1 else rate_limit="$1" video_url="$2" fi # update youtube-dl if needed yt-dlp --update # download channel, preserving metadata, combining into single .mkv per video yt-dlp \ --concurrent-fragments 8 \ --console-title \ --continue \ --convert-thumbnails png \ --download-archive .archive \ --embed-metadata \ --embed-subs \ --embed-thumbnail \ --format 'bv*+ba/b' \ --fragment-retries infinite \ --geo-bypass \ --limit-rate "${rate_limit}" \ --merge-output-format mkv \ --output '%(playlist_autonumber)000006d - %(title)s.%(ext)s' \ --prefer-free-formats \ --restrict-filenames \ --retries infinite \ --sponsorblock-mark "all" \ --sub-langs "en.*,live_chat" \ --write-annotations \ --write-auto-subs \ --write-comments \ --write-description \ --write-info-json \ --write-playlist-metafiles \ --write-subs \ --write-thumbnail \ --xattrs \ --yes-playlist \ "${video_url}"