From f320d1d494b56c2958a019c35e131f751cf6e1c7 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Mon, 26 Jan 2026 22:40:32 +0100 Subject: [PATCH] minor --- hosts/nixos/nfss/home.nix | 2 +- modules/yt-dlp.nix | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hosts/nixos/nfss/home.nix b/hosts/nixos/nfss/home.nix index 6facc3d..2c8f1f9 100644 --- a/hosts/nixos/nfss/home.nix +++ b/hosts/nixos/nfss/home.nix @@ -14,7 +14,7 @@ programs.yt-dlp-custom = { enable = true; - downloadDir = "/home/yanlin/Downloads"; + downloadDir = "/home/yanlin/Media"; }; } diff --git a/modules/yt-dlp.nix b/modules/yt-dlp.nix index e6065ea..43ea1de 100644 --- a/modules/yt-dlp.nix +++ b/modules/yt-dlp.nix @@ -204,15 +204,17 @@ description=$description ABSMETA local thumb_file="" + local thumb_ext="" for ext in jpg webp png; do if [[ -f "$dir/$name_noext.$ext" ]]; then thumb_file="$dir/$name_noext.$ext" + thumb_ext="$ext" break fi done if [[ -n "$thumb_file" ]]; then - mv "$thumb_file" "$dir/cover.jpg" 2>/dev/null + mv "$thumb_file" "$dir/cover.$thumb_ext" 2>/dev/null fi } @@ -227,11 +229,16 @@ ABSMETA local days_filter="" local audio_only=false local max_resolution="" + local custom_download_dir="" local url="" # Parse arguments while [[ $# -gt 0 ]]; do case "$1" in + -d|--dir) + custom_download_dir="$2" + shift 2 + ;; -n|--count) max_downloads="$2" shift 2 @@ -285,6 +292,7 @@ ABSMETA echo " youtube|bilibili Platform to download from" echo "" echo "Options:" + echo " -d, --dir Override download directory" echo " -n, --count Limit number of videos to process/download" echo " -r, --retries Number of retry attempts (0 for no retries, default: 10)" echo " --min Minimum video duration in minutes" @@ -302,12 +310,19 @@ ABSMETA echo " dlv bilibili -n 10 - Download first 10 videos" echo " dlv youtube -a - Download audio only" echo " dlv youtube --res 720 - Download max 720p video" + echo " dlv youtube -d /mnt/media - Download to custom directory" return 1 fi # Override MAX_RETRIES if specified [[ -n "$custom_retries" ]] && local MAX_RETRIES="$custom_retries" + # Override download directory if specified + local DOWNLOAD_DIR="$DOWNLOAD_DIR" + if [[ -n "$custom_download_dir" ]]; then + DOWNLOAD_DIR="''${custom_download_dir/#\~/$HOME}" + fi + # Platform-specific configuration local cookies_file platform_name platform_flags case "$platform" in