From: Steven Baltakatei Sandoval Date: Thu, 25 Jul 2024 21:29:15 +0000 (+0000) Subject: style(user/bkytpldl-generic):Cleanup script settings section X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/2a4d0fe27da3613470cc2f19d3586acb44900499?ds=sidebyside style(user/bkytpldl-generic):Cleanup script settings section --- diff --git a/user/bkytpldl-generic b/user/bkytpldl-generic index ce019e8..d94bfac 100644 --- a/user/bkytpldl-generic +++ b/user/bkytpldl-generic @@ -1,17 +1,17 @@ #!/usr/bin/env bash # Desc: Download YouTube videos # Usage: $ ./bkytpldl-generic -# Version: 4.0.0 - -# Adjust me -dir_out="~/Videos/"; -url_playlist1="https://www.youtube.com/playlist?list=PLxxx"; -url_playlist2="https://www.youtube.com/playlist?list=PLxxx"; -url_playlist3="https://www.youtube.com/playlist?list=PLxxx"; +# Version: 4.1.0 declare -a args; # array for yt-dlp arguments declare -a urls urls_rand; # array for YouTube playlist URLs +# Settings +dir_out="~/Videos/"; +urls+=("https://www.youtube.com/playlist?list=PLxxx"); # adjust me +urls+=("https://www.youtube.com/playlist?list=PLxxx"); # adjust me +urls+=("https://www.youtube.com/playlist?list=PLxxx"); # adjust me + yell() { echo "$0: $*" >&2; } # print script path and all args to stderr die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status must() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails @@ -25,7 +25,7 @@ if pgrep "^yt-dlp$" 1>/dev/random 2>&1; then die "FATAL:yt-dlp already running." # Check directories if [[ ! -d $dir_out ]]; then mkdir -p "$dir_out"; fi; -# == Download Video == +# == Assemble options == # yt-dlp output options ## Restrict file name character set @@ -89,9 +89,6 @@ args+=("%(playlist)s/%(upload_date)s.%(channel)s.%(channel_id)s.%(title).120B.%( args+=("-S" "res:1080"); ## Specify playlist URLs to download -urls+=("$url_playlist1"); -urls+=("$url_playlist2"); -urls+=("$url_playlist3"); ### Shuffle playlist download order mapfile -t urls_rand < <(printf "%s\n" "${urls[@]}" | shuf); for url in "${urls_rand[@]}"; do @@ -101,7 +98,8 @@ done; # Change working directory to output dir pushd "$dir_out" || die "FATAL:Failed to change pwd to:dir_out:$dir_out"; -# Download videos +# == Download videos == + #yell "DEBUG:args:$(declare -p args)"; # debug command must yt-dlp "${args[@]}"; # execute command popd || die "FATAL:Failed to return from dir_out:$dir_out";