Skip to content

Commit

Permalink
chore: 减少并发下载量与 read_timeout 值 (#96)
Browse files Browse the repository at this point in the history
* chore: 减少并发下载量与 read_timeout 值

* chore: 修正注释
  • Loading branch information
amtoaer committed May 3, 2024
1 parent f044b18 commit cd2bd9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bilibili/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
Expand Down
8 changes: 4 additions & 4 deletions src/core/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<i64, (Mutex<()>, Mutex<()>)> = HashMap::new();
for (video_model, _) in &unhandled_videos_pages {
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit cd2bd9c

Please sign in to comment.