X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/cb0f307f5af95dd07eb32050bc060342f0097f54..8bc49658c267d4380450b167b21253d127d4977f:/user/bkytpldl-generic?ds=inline diff --git a/user/bkytpldl-generic b/user/bkytpldl-generic index ce019e8..ae79832 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.1 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. YouTube playlist URL goes here +urls+=("https://www.youtube.com/playlist?list=PLxxx"); # Adjust me. YouTube playlist URL goes here +urls+=("https://www.youtube.com/playlist?list=PLxxx"); # Adjust me. YouTube playlist URL goes here + 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";