From cd2bd9cbb30f380aeec11ceccffd4334cadd9b48 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: Fri, 3 May 2024 12:48:53 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=87=8F=E5=B0=91=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E9=87=8F=E4=B8=8E=20read=5Ftimeout=20?= =?UTF-8?q?=E5=80=BC=20(#96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 减少并发下载量与 read_timeout 值 * chore: 修正注释 --- src/bilibili/client.rs | 2 +- src/core/command.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bilibili/client.rs b/src/bilibili/client.rs index b62355d..206d3eb 100644 --- a/src/bilibili/client.rs +++ b/src/bilibili/client.rs @@ -29,7 +29,7 @@ impl Client { .default_headers(headers) .gzip(true) .connect_timeout(std::time::Duration::from_secs(10)) - .read_timeout(std::time::Duration::from_secs(30)) + .read_timeout(std::time::Duration::from_secs(10)) .build() .unwrap(), ) diff --git a/src/core/command.rs b/src/core/command.rs index 0e9d379..428e68c 100644 --- a/src/core/command.rs +++ b/src/core/command.rs @@ -157,8 +157,8 @@ pub async fn download_unprocessed_videos( favorite_model.f_id, favorite_model.name ); let unhandled_videos_pages = unhandled_videos_pages(&favorite_model, connection).await?; - // 对于视频,允许五个同时下载(视频内还有分页、不同分页还有多种下载任务) - let semaphore = Semaphore::new(5); + // 对于视频,允许三个同时下载(视频内还有分页、不同分页还有多种下载任务) + let semaphore = Semaphore::new(3); let downloader = Downloader::new(bili_client.client.clone()); let mut uppers_mutex: HashMap, Mutex<()>)> = HashMap::new(); for (video_model, _) in &unhandled_videos_pages { @@ -312,8 +312,8 @@ pub async fn dispatch_download_page( if !should_run { return Ok(()); } - // 对于视频的分页,允许同时下载三个同时下载(绝大部分是单页视频) - let child_semaphore = Semaphore::new(5); + // 对于视频的分页,允许两个同时下载(绝大部分是单页视频) + let child_semaphore = Semaphore::new(2); let mut tasks = pages .into_iter() .map(|page_model| download_page(bili_client, video_model, page_model, &child_semaphore, downloader))