Skip to content

Commit

Permalink
Merge pull request #143 from alley-rs/dev
Browse files Browse the repository at this point in the history
fix(parser/bilibili): 修复 CookieVerifier 请求和反序列化错误处理
  • Loading branch information
thep0y authored Dec 13, 2024
2 parents 45e4fa7 + 2b052d0 commit f767702
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src-tauri/src/parser/bilibili/cookie_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use reqwest::Client;
use serde::Deserialize;
use serde_json::Value;

use crate::error::LsarResult;
use crate::error::{LsarError, LsarResult};

const VERIFY_URL: &str = "https://api.bilibili.com/x/web-interface/nav";

Expand Down Expand Up @@ -37,9 +37,17 @@ impl<'a> CookieVerifier<'a> {
.get(VERIFY_URL)
.header("Cookie", self.cookie)
.send()
.await?
.await
.map_err(|e| {
error!("Failed to send reqeust: {:?}", e);
LsarError::Other("Cookie is invalid".to_owned())
})?
.json::<Value>()
.await?;
.await
.map_err(|e| {
error!("Failed to deserialize response: {}", e);
e
})?;

debug!("Cookie verification result: {}", response_value);

Expand Down

0 comments on commit f767702

Please sign in to comment.