Skip to content

Commit

Permalink
Merge pull request #282 from cxu-fork/fix-bili-cookie
Browse files Browse the repository at this point in the history
修复 bili 带 cookie 时不能获取原画的问题  (#277)
  • Loading branch information
Borber authored Nov 30, 2023
2 parents 3871155 + 0d82de1 commit 802c292
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/core/src/live/bili.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Live for Client {
_ => return Err(SeamError::None),
};

let mut stream_info = get_bili_stream_info(&rid, 10000).await?;
let mut stream_info = get_bili_stream_info(&rid, 10000, headers).await?;

let max = stream_info
.as_array()
Expand All @@ -61,7 +61,7 @@ impl Live for Client {
.ok_or(SeamError::NeedFix("max"))?;

if max != 10000 {
stream_info = get_bili_stream_info(&rid, max).await?;
stream_info = get_bili_stream_info(&rid, max, headers).await?;
}

let mut urls = vec![];
Expand Down Expand Up @@ -132,10 +132,13 @@ impl Live for Client {
}

/// 通过真实房间号获取直播源信息
pub async fn get_bili_stream_info(rid: &str, qn: u64) -> Result<serde_json::Value> {
/// 不带 cookie 只给 480P, 带 cookie 才给原画画质
pub async fn get_bili_stream_info(rid: &str, qn: u64, headers: Option<HashMap<String, String>>) -> Result<serde_json::Value> {
let mut headers = hash2header(headers);
headers.append("User-Agent", HeaderValue::from_static(USER_AGENT));
Ok(CLIENT
.get(PLAY_URL)
.header("User-Agent", USER_AGENT)
.headers(headers)
.query(&[
("room_id", rid),
("protocol", "0,1"),
Expand Down

0 comments on commit 802c292

Please sign in to comment.