Add retry parameter to dl alias

This commit is contained in:
Yan Lin 2025-10-04 22:32:28 +02:00
parent 8dfaabfef0
commit 5ba9060e08
2 changed files with 61 additions and 24 deletions

View file

@ -22,17 +22,17 @@
interval = "*-*-* 08:00:00";
randomDelay = "1h";
commands = [
"dl-yt -n 3 'https://www.youtube.com/@KitbogaShow/videos'"
"dl-yt -n 3 'https://www.youtube.com/@JCS/videos'"
"dl-yt -n 3 'https://www.youtube.com/@Shane_McGillicuddy/videos'"
"dl-yt -n 3 'https://www.youtube.com/@Coffeezilla/videos'"
"dl-yt -n 3 'https://www.youtube.com/@Danny-Gonzalez/videos'"
"dl-yt -n 3 'https://www.youtube.com/@rejectconvenience/videos'"
"dl-yt -n 3 'https://www.youtube.com/@StuffMadeHere/videos'"
"dl-yt -n 3 'https://www.youtube.com/@AdamSomething/videos'"
"dl-yt -n 3 'https://www.youtube.com/@_gerg/videos'"
"dl-yt -n 3 'https://www.youtube.com/@Yeah_Jaron/videos'"
"dl-yt -n 3 'https://www.youtube.com/@WolfgangsChannel/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@KitbogaShow/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@JCS/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@Shane_McGillicuddy/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@Coffeezilla/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@Danny-Gonzalez/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@rejectconvenience/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@StuffMadeHere/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@AdamSomething/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@_gerg/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@Yeah_Jaron/videos'"
"dl-yt -n 3 -r 1 'https://www.youtube.com/@WolfgangsChannel/videos'"
];
};

View file

@ -144,6 +144,7 @@ in
# YouTube single video download
download-youtube() {
local max_downloads=""
local custom_retries=""
local url=""
# Parse arguments
@ -153,6 +154,10 @@ in
max_downloads="$2"
shift 2
;;
-r|--retries)
custom_retries="$2"
shift 2
;;
*)
url="$url $1"
shift
@ -163,11 +168,15 @@ in
url="''${url## }" # Trim leading space
if [[ -z "$url" ]]; then
echo "Usage: dl-yt [-n|--max <number>] <url>"
echo "Usage: dl-yt [-n|--max <number>] [-r|--retries <number>] <url>"
echo " -n, --max <number> Limit number of videos to process (useful for channels/playlists)"
echo " -r, --retries <number> Number of retry attempts (0 for no retries, default: 10)"
return 1
fi
# Override MAX_RETRIES if specified
[[ -n "$custom_retries" ]] && local MAX_RETRIES="$custom_retries"
local cookies_file="$HOME/.config/yt-dlp/cookies-youtube.txt"
local temp_cookies=$(_setup_temp_cookies "$cookies_file")
local output_template="$DOWNLOAD_DIR/YouTube/%(uploader|)s/%(upload_date>%Y%m%d|)s-%(title)s.%(ext)s"
@ -200,6 +209,7 @@ in
# YouTube playlist download
download-youtube-playlist() {
local max_downloads=""
local custom_retries=""
local url=""
# Parse arguments
@ -209,6 +219,10 @@ in
max_downloads="$2"
shift 2
;;
-r|--retries)
custom_retries="$2"
shift 2
;;
*)
url="$url $1"
shift
@ -219,11 +233,15 @@ in
url="''${url## }" # Trim leading space
if [[ -z "$url" ]]; then
echo "Usage: dl-yt-p [-n|--max <number>] <playlist-url>"
echo "Usage: dl-yt-p [-n|--max <number>] [-r|--retries <number>] <playlist-url>"
echo " -n, --max <number> Limit number of videos to download"
echo " -r, --retries <number> Number of retry attempts (0 for no retries, default: 10)"
return 1
fi
# Override MAX_RETRIES if specified
[[ -n "$custom_retries" ]] && local MAX_RETRIES="$custom_retries"
local cookies_file="$HOME/.config/yt-dlp/cookies-youtube.txt"
local temp_cookies=$(_setup_temp_cookies "$cookies_file")
local output_template="$DOWNLOAD_DIR/YouTube/%(uploader|)s-%(playlist|)s/%(playlist_index|)03d-%(title)s.%(ext)s"
@ -256,6 +274,7 @@ in
# Bilibili single video download
download-bilibili() {
local max_downloads=""
local custom_retries=""
local url=""
# Parse arguments
@ -265,6 +284,10 @@ in
max_downloads="$2"
shift 2
;;
-r|--retries)
custom_retries="$2"
shift 2
;;
*)
url="$url $1"
shift
@ -275,11 +298,15 @@ in
url="''${url## }" # Trim leading space
if [[ -z "$url" ]]; then
echo "Usage: dl-bili [-n|--max <number>] <url>"
echo "Usage: dl-bili [-n|--max <number>] [-r|--retries <number>] <url>"
echo " -n, --max <number> Limit number of videos to process (useful for channels/playlists)"
echo " -r, --retries <number> Number of retry attempts (0 for no retries, default: 10)"
return 1
fi
# Override MAX_RETRIES if specified
[[ -n "$custom_retries" ]] && local MAX_RETRIES="$custom_retries"
local cookies_file="$HOME/.config/yt-dlp/cookies-bilibili.txt"
local temp_cookies=$(_setup_temp_cookies "$cookies_file")
local output_template="$DOWNLOAD_DIR/Bilibili/%(uploader|)s/%(upload_date>%Y%m%d|)s-%(title)s.%(ext)s"
@ -312,6 +339,7 @@ in
# Bilibili playlist/collection download
download-bilibili-playlist() {
local max_downloads=""
local custom_retries=""
local url=""
# Parse arguments
@ -321,6 +349,10 @@ in
max_downloads="$2"
shift 2
;;
-r|--retries)
custom_retries="$2"
shift 2
;;
*)
url="$url $1"
shift
@ -331,11 +363,15 @@ in
url="''${url## }" # Trim leading space
if [[ -z "$url" ]]; then
echo "Usage: dl-bili-p [-n|--max <number>] <playlist-url>"
echo "Usage: dl-bili-p [-n|--max <number>] [-r|--retries <number>] <playlist-url>"
echo " -n, --max <number> Limit number of videos to download"
echo " -r, --retries <number> Number of retry attempts (0 for no retries, default: 10)"
return 1
fi
# Override MAX_RETRIES if specified
[[ -n "$custom_retries" ]] && local MAX_RETRIES="$custom_retries"
local cookies_file="$HOME/.config/yt-dlp/cookies-bilibili.txt"
local temp_cookies=$(_setup_temp_cookies "$cookies_file")
local output_template="$DOWNLOAD_DIR/Bilibili/%(uploader|)s-%(playlist|)s/%(playlist_index|)03d-%(title)s.%(ext)s"
@ -371,15 +407,16 @@ in
Video Download Commands:
YouTube:
dl-yt [-n <N>] <url> - Download single YouTube video
dl-yt-p [-n <N>] <url> - Download YouTube playlist
dl-yt [-n <N>] [-r <R>] <url> - Download single YouTube video
dl-yt-p [-n <N>] [-r <R>] <url> - Download YouTube playlist
Bilibili:
dl-bili [-n <N>] <url> - Download single Bilibili video
dl-bili-p [-n <N>] <url> - Download Bilibili playlist/collection
dl-bili [-n <N>] [-r <R>] <url> - Download single Bilibili video
dl-bili-p [-n <N>] [-r <R>] <url> - Download Bilibili playlist/collection
Options:
-n, --max <number> Limit number of videos to process/download
-r, --retries <number> Number of retry attempts (0 for no retries, default: 10)
Other commands:
dl-clear-archive - Clear download history (allows re-downloading)