X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/cb0f307f5af95dd07eb32050bc060342f0097f54..df7774c1d8ac3cddfbf1f209a9ac437d82eabb35:/user/bkytpldl-generic diff --git a/user/bkytpldl-generic b/user/bkytpldl-generic index ce019e8..4f6689f 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.2 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 @@ -83,15 +83,12 @@ args+=("--download-archive" "$pathDA"); ## Note: `$(title).120B` shortens title to 120 bytes (useful for ## titles with UTF-8 characters. args+=("-o"); -args+=("%(playlist)s/%(upload_date)s.%(channel)s.%(channel_id)s.%(title).120B.%(id)s.%(ext)s"); +args+=("%(playlist)s/%(upload_date)s.%(channel).32B.%(channel_id)s.%(title).120B.%(id)s.%(ext)s"); ## Limit download resolution to 1080p 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";