diff --git a/hosts/nixos/hs/home.nix b/hosts/nixos/hs/home.nix index 08c517e..0ee1e58 100644 --- a/hosts/nixos/hs/home.nix +++ b/hosts/nixos/hs/home.nix @@ -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'" ]; }; diff --git a/modules/yt-dlp.nix b/modules/yt-dlp.nix index 178f20a..1dd5e68 100644 --- a/modules/yt-dlp.nix +++ b/modules/yt-dlp.nix @@ -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 ] " - echo " -n, --max Limit number of videos to process (useful for channels/playlists)" + echo "Usage: dl-yt [-n|--max ] [-r|--retries ] " + echo " -n, --max Limit number of videos to process (useful for channels/playlists)" + echo " -r, --retries 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 ] " - echo " -n, --max Limit number of videos to download" + echo "Usage: dl-yt-p [-n|--max ] [-r|--retries ] " + echo " -n, --max Limit number of videos to download" + echo " -r, --retries 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 ] " - echo " -n, --max Limit number of videos to process (useful for channels/playlists)" + echo "Usage: dl-bili [-n|--max ] [-r|--retries ] " + echo " -n, --max Limit number of videos to process (useful for channels/playlists)" + echo " -r, --retries 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 ] " - echo " -n, --max Limit number of videos to download" + echo "Usage: dl-bili-p [-n|--max ] [-r|--retries ] " + echo " -n, --max Limit number of videos to download" + echo " -r, --retries 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 ] - Download single YouTube video - dl-yt-p [-n ] - Download YouTube playlist + dl-yt [-n ] [-r ] - Download single YouTube video + dl-yt-p [-n ] [-r ] - Download YouTube playlist Bilibili: - dl-bili [-n ] - Download single Bilibili video - dl-bili-p [-n ] - Download Bilibili playlist/collection + dl-bili [-n ] [-r ] - Download single Bilibili video + dl-bili-p [-n ] [-r ] - Download Bilibili playlist/collection Options: - -n, --max Limit number of videos to process/download + -n, --max Limit number of videos to process/download + -r, --retries Number of retry attempts (0 for no retries, default: 10) Other commands: dl-clear-archive - Clear download history (allows re-downloading)