mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-08 17:09:14 +08:00
chore: 补上缺失的 error_for_status 调用,修改一个 clippy 格式错误 (#273)
This commit is contained in:
@@ -55,6 +55,7 @@ impl Credential {
|
|||||||
.request(Method::GET, "https://api.bilibili.com/x/web-interface/nav", Some(self))
|
.request(Method::GET, "https://api.bilibili.com/x/web-interface/nav", Some(self))
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
|
.error_for_status()?
|
||||||
.json::<serde_json::Value>()
|
.json::<serde_json::Value>()
|
||||||
.await?
|
.await?
|
||||||
.validate()?;
|
.validate()?;
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ impl<'a> Video<'a> {
|
|||||||
))
|
))
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
|
.error_for_status()?
|
||||||
.json::<serde_json::Value>()
|
.json::<serde_json::Value>()
|
||||||
.await?
|
.await?
|
||||||
.validate()?;
|
.validate()?;
|
||||||
@@ -198,6 +199,7 @@ impl<'a> Video<'a> {
|
|||||||
.request(Method::GET, format!("https:{}", &info.subtitle_url).as_str(), None)
|
.request(Method::GET, format!("https:{}", &info.subtitle_url).as_str(), None)
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
|
.error_for_status()?
|
||||||
.json::<serde_json::Value>()
|
.json::<serde_json::Value>()
|
||||||
.await?;
|
.await?;
|
||||||
let body: SubTitleBody = serde_json::from_value(res["body"].take())?;
|
let body: SubTitleBody = serde_json::from_value(res["body"].take())?;
|
||||||
|
|||||||
@@ -26,7 +26,12 @@ impl Downloader {
|
|||||||
fs::create_dir_all(parent).await?;
|
fs::create_dir_all(parent).await?;
|
||||||
}
|
}
|
||||||
let mut file = File::create(path).await?;
|
let mut file = File::create(path).await?;
|
||||||
let resp = self.client.request(Method::GET, url, None).send().await?;
|
let resp = self
|
||||||
|
.client
|
||||||
|
.request(Method::GET, url, None)
|
||||||
|
.send()
|
||||||
|
.await?
|
||||||
|
.error_for_status()?;
|
||||||
let expected = resp.content_length().unwrap_or_default();
|
let expected = resp.content_length().unwrap_or_default();
|
||||||
let mut stream_reader = StreamReader::new(resp.bytes_stream().map_err(std::io::Error::other));
|
let mut stream_reader = StreamReader::new(resp.bytes_stream().map_err(std::io::Error::other));
|
||||||
let received = tokio::io::copy(&mut stream_reader, &mut file).await?;
|
let received = tokio::io::copy(&mut stream_reader, &mut file).await?;
|
||||||
|
|||||||
@@ -114,8 +114,7 @@ impl<const N: usize> Status<N> {
|
|||||||
if let ExecutionStatus::FixedFailed(status, _) = result {
|
if let ExecutionStatus::FixedFailed(status, _) = result {
|
||||||
assert!(*status < 0b1000, "status should be less than 0b1000");
|
assert!(*status < 0b1000, "status should be less than 0b1000");
|
||||||
self.set_status(offset, *status);
|
self.set_status(offset, *status);
|
||||||
} else {
|
} else if self.get_status(offset) < STATUS_MAX_RETRY {
|
||||||
if self.get_status(offset) < STATUS_MAX_RETRY {
|
|
||||||
match result {
|
match result {
|
||||||
ExecutionStatus::Succeeded | ExecutionStatus::Skipped => self.set_ok(offset),
|
ExecutionStatus::Succeeded | ExecutionStatus::Skipped => self.set_ok(offset),
|
||||||
ExecutionStatus::Failed(_) => self.plus_one(offset),
|
ExecutionStatus::Failed(_) => self.plus_one(offset),
|
||||||
@@ -124,7 +123,6 @@ impl<const N: usize> Status<N> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<const N: usize> From<u32> for Status<N> {
|
impl<const N: usize> From<u32> for Status<N> {
|
||||||
fn from(status: u32) -> Self {
|
fn from(status: u32) -> Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user