ytdl-wrapper.sh (1998B)
1 #!/usr/bin/env bash 2 3 # yt-dlp wrapper script 4 5 aria_args=() 6 metadata_args=() 7 cookies_args=() 8 archive_args=() 9 other_args=() 10 output_format_args=(-o "%(title)s.%(ext)s") 11 format_args=() 12 13 while [[ $# -gt 0 ]]; do 14 case "$1" in 15 --aria) 16 aria_args+=("--external-downloader" "aria2c" "--external-downloader-args" "aria2c:-x 16 -j 16 -s 16 -k 1M") 17 shift 18 ;; 19 --aria-limit) 20 download_limit="3" 21 num_re='^[0-9]+M*$' 22 if [[ "$2" =~ $num_re ]]; then 23 download_limit="${2//M}" 24 shift 25 fi 26 aria_args+=("--external-downloader" "aria2c" "--external-downloader-args" "aria2c:-x 16 -j 16 -s 16 -k 1M --max-overall-download-limit=${download_limit}M") 27 shift 28 ;; 29 --all-metadata) 30 metadata_args+=("--embed-chapters" "--embed-thumbnail" "--embed-metadata") 31 shift 32 ;; 33 --music) 34 output_format_args=(-o "%(title)s -- %(channel)s -- %(album)s.%(ext)s") 35 format_args=(-f 140) 36 shift 37 ;; 38 --playlist-order) 39 output_format_args=(-o "%(playlist_index)s-%(title)s.%(ext)s") 40 shift 41 ;; 42 --standard) 43 format_args=(-f "22/bestvideo[height<=720]+bestaudio") 44 shift 45 ;; 46 --firefox-cookies) 47 cookies_args=("--cookies-from-browser" "firefox") 48 shift 49 ;; 50 --archive) 51 archive_args=("--download-archive" "archive.txt") 52 shift 53 ;; 54 --1080p) 55 format_args=("-f" "bestvideo[height<=1080][protocol=https][vcodec*=avc]+bestaudio[ext=m4a]") 56 shift 57 ;; 58 --720p) 59 format_args=("-f" "bestvideo[height<=720][protocol=https][vcodec*=avc]+bestaudio[ext=m4a]") 60 shift 61 ;; 62 --480p) 63 format_args=("-f" "bestvideo[height<=480][protocol=https][vcodec*=avc]+bestaudio[ext=m4a]") 64 shift 65 ;; 66 --360p) 67 format_args=("-f" "bestvideo[height<=360][protocol=https][vcodec*=avc]+bestaudio[ext=m4a]") 68 shift 69 ;; 70 *) 71 other_args+=("$1") 72 shift 73 ;; 74 esac 75 done 76 77 all_args=("${output_format_args[@]}" "${aria_args[@]}" "${metadata_args[@]}" "${cookies_args[@]}" "${format_args[@]}" "${archive_args[@]}" "${other_args[@]}" "$@") 78 /usr/bin/yt-dlp "${all_args[@]}"