From d1eac3e298fa507cdca7289fea69266b28e1938e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Sat, 6 Dec 2025 23:26:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E5=87=AD=E8=AF=81=E6=A3=80=E6=9F=A5=E5=88=B7=E6=96=B0=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=EF=BC=8C=E7=94=B1=E7=94=A8=E6=88=B7=E8=87=AA=E8=A1=8C?= =?UTF-8?q?=E7=BB=B4=E6=8A=A4=20credential=20=E6=9C=89=E6=95=88=E6=80=A7?= =?UTF-8?q?=20(#560)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/bili_sync/src/config/args.rs | 3 +++ crates/bili_sync/src/task/video_downloader.rs | 26 +++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/crates/bili_sync/src/config/args.rs b/crates/bili_sync/src/config/args.rs index d98e244..def629f 100644 --- a/crates/bili_sync/src/config/args.rs +++ b/crates/bili_sync/src/config/args.rs @@ -13,6 +13,9 @@ pub struct Args { #[arg(short, long, default_value = "None,bili_sync=info", env = "RUST_LOG")] pub log_level: String, + + #[arg(short, long, env = "DISABLE_CREDENTIAL_REFRESH")] + pub disable_credential_refresh: bool, } mod built_info { diff --git a/crates/bili_sync/src/task/video_downloader.rs b/crates/bili_sync/src/task/video_downloader.rs index d7c5e90..8db6771 100644 --- a/crates/bili_sync/src/task/video_downloader.rs +++ b/crates/bili_sync/src/task/video_downloader.rs @@ -10,7 +10,7 @@ use tokio_cron_scheduler::{Job, JobScheduler}; use crate::adapter::VideoSource; use crate::bilibili::{self, BiliClient, BiliError}; -use crate::config::{Config, TEMPLATE, Trigger, VersionedConfig}; +use crate::config::{ARGS, Config, TEMPLATE, Trigger, VersionedConfig}; use crate::utils::model::get_enabled_video_sources; use crate::utils::notify::error_and_notify; use crate::workflow::process_video_source; @@ -109,16 +109,20 @@ impl DownloadTaskManager { // 读取初始配置 let mut rx = VersionedConfig::get().subscribe(); let initial_config = rx.borrow_and_update().clone(); - // 初始化凭据检查与刷新任务,该任务必须成功,否则直接退出 - sched - .lock() - .await - .add(Job::new_async_tz( - "0 0 1 * * *", - chrono::Local, - DownloadTaskManager::check_and_refresh_credential_task(cx.clone()), - )?) - .await?; + if ARGS.disable_credential_refresh { + warn!("已禁用凭据检查与刷新任务,bili-sync 将不会自动检查刷新 Credential,需要用户自行维护"); + } else { + // 初始化凭据检查与刷新任务,该任务必须成功,否则直接退出 + sched + .lock() + .await + .add(Job::new_async_tz( + "0 0 1 * * *", + chrono::Local, + DownloadTaskManager::check_and_refresh_credential_task(cx.clone()), + )?) + .await?; + } // 初始化并添加视频下载任务,将任务 ID 保存到 TaskManager 中 let video_task_id = async { let job_run = DownloadTaskManager::download_video_task(cx.clone());