Skip to content

Commit

Permalink
fix: 修复风控判断错误,以及可能的阻塞问题 (#77)
Browse files Browse the repository at this point in the history
* fix: 尝试修复风控判断错误,以及可能的阻塞问题

* fix: 继续修复
  • Loading branch information
amtoaer authored Apr 25, 2024
1 parent be4f62d commit 1ad82e5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 26 deletions.
49 changes: 28 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ prost = "0.12.4"
quick-xml = { version = "0.31.0", features = ["async-tokio"] }
rand = "0.8.5"
regex = "1.10.3"
reqwest = { version = "0.12.0", features = [
reqwest = { version = "0.12.4", features = [
"json",
"stream",
"cookies",
Expand Down
2 changes: 2 additions & 0 deletions src/bilibili/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ impl Client {
reqwest::Client::builder()
.default_headers(headers)
.gzip(true)
.connect_timeout(std::time::Duration::from_secs(10))
.read_timeout(std::time::Duration::from_secs(30))
.build()
.unwrap(),
)
Expand Down
9 changes: 5 additions & 4 deletions src/core/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ pub async fn download_video_pages(
),
});
if let Err(e) = results.into_iter().nth(4).unwrap() {
if let Ok(e) = e.downcast::<DownloadAbortError>() {
return Err(e.into());
if e.downcast_ref::<DownloadAbortError>().is_some() {
return Err(e);
}
}
let mut video_active_model: video::ActiveModel = video_model.into();
Expand Down Expand Up @@ -335,6 +335,7 @@ pub async fn dispatch_download_page(
}
Err(e) => {
if e.downcast_ref::<DownloadAbortError>().is_some() {
should_error = true;
is_break = true;
break;
}
Expand Down Expand Up @@ -472,8 +473,8 @@ pub async fn download_page(
});
// 查看下载视频的状态,该状态会影响上层是否 break
if let Err(e) = results.into_iter().nth(1).unwrap() {
if let Ok(e) = e.downcast::<DownloadAbortError>() {
return Err(e.into());
if let Ok(BiliError::RiskControlOccurred) = e.downcast::<BiliError>() {
bail!(DownloadAbortError());
}
}
let mut page_active_model: page::ActiveModel = page_model.into();
Expand Down

0 comments on commit 1ad82e5

Please sign in to comment.