Merge pull request #83 from lanyeeee/develop

Develop
This commit is contained in:
lanyeeee
2026-08-02 09:29:12 +08:00
committed by GitHub
6 changed files with 18 additions and 6 deletions
+13 -1
View File
@@ -120,6 +120,15 @@ impl BiliClient {
let http_resp = request.send().await?; let http_resp = request.send().await?;
// 检查http响应状态码 // 检查http响应状态码
let status = http_resp.status(); let status = http_resp.status();
// 尝试从headers中拿SESSDATA
let sessdata = http_resp
.headers()
.get_all("set-cookie")
.iter()
.filter_map(|header| header.to_str().ok())
.filter_map(|header| header.split(';').next())
.filter_map(|cookie| cookie.split_once('='))
.find_map(|(key, value)| (key.trim() == "SESSDATA").then(|| value.to_owned()));
let body = http_resp.text().await?; let body = http_resp.text().await?;
if status != StatusCode::OK { if status != StatusCode::OK {
return Err(eyre!("预料之外的状态码({status}): {body}")); return Err(eyre!("预料之外的状态码({status}): {body}"));
@@ -137,11 +146,14 @@ impl BiliClient {
}; };
// 尝试将data解析为二维码状态 // 尝试将data解析为二维码状态
let data_str = data.to_string(); let data_str = data.to_string();
let qrcode_status: QrcodeStatus = serde_json::from_str(&data_str) let mut qrcode_status: QrcodeStatus = serde_json::from_str(&data_str)
.wrap_err(format!("将data解析为QrcodeStatus失败: {data_str}"))?; .wrap_err(format!("将data解析为QrcodeStatus失败: {data_str}"))?;
if ![0, 86101, 86090, 86038].contains(&qrcode_status.code) { if ![0, 86101, 86090, 86038].contains(&qrcode_status.code) {
return Err(eyre!("预料之外的二维码code: {qrcode_status:?}")); return Err(eyre!("预料之外的二维码code: {qrcode_status:?}"));
} }
if qrcode_status.code == 0 {
qrcode_status.sessdata = sessdata.ok_or_eyre("扫码成功,但没有解析到SESSDATA")?;
}
Ok(qrcode_status) Ok(qrcode_status)
} }
+1 -1
View File
@@ -67,7 +67,7 @@ impl ChapterSegments {
// 遍历完所有现有片段并处理完所有重叠后,将新的片段添加到结果列表中 // 遍历完所有现有片段并处理完所有重叠后,将新的片段添加到结果列表中
processed_segments.push(new_segment); processed_segments.push(new_segment);
processed_segments.sort_by(|a, b| a.start.cmp(&b.start)); processed_segments.sort_by_key(|a| a.start);
self.segments = processed_segments; self.segments = processed_segments;
} }
+1
View File
@@ -5,6 +5,7 @@ use specta::Type;
#[serde(default)] #[serde(default)]
pub struct QrcodeStatus { pub struct QrcodeStatus {
pub url: String, pub url: String,
pub sessdata: String,
pub refresh_token: String, pub refresh_token: String,
pub timestamp: i64, pub timestamp: i64,
pub code: i64, pub code: i64,
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "bilibili-video-downloader", "productName": "bilibili-video-downloader",
"version": "0.2.0", "version": "0.2.1",
"identifier": "com.lanyeeee.bilibili-video-downloader", "identifier": "com.lanyeeee.bilibili-video-downloader",
"build": { "build": {
"beforeDevCommand": "pnpm dev", "beforeDevCommand": "pnpm dev",
+1 -1
View File
@@ -424,7 +424,7 @@ export type PurchaseFormatNote = { content_list: ContentList[]; link: string; ti
export type PurchaseNote = { content: string; link: string; title: string } export type PurchaseNote = { content: string; link: string; title: string }
export type PurchaseProtocol = { link: string; title: string } export type PurchaseProtocol = { link: string; title: string }
export type QrcodeData = { url: string; qrcode_key: string } export type QrcodeData = { url: string; qrcode_key: string }
export type QrcodeStatus = { url: string; refresh_token: string; timestamp: number; code: number; message: string } export type QrcodeStatus = { url: string; sessdata: string; refresh_token: string; timestamp: number; code: number; message: string }
export type RatingInBangumi = { count: number; score: number } export type RatingInBangumi = { count: number; score: number }
export type RatingInBangumiFollow = { score: number; count: number } export type RatingInBangumiFollow = { score: number; count: number }
export type RecommendSeason = { cover: string; ep_count: string; id: number; season_url: string; subtitle: string; title: string; view: number } export type RecommendSeason = { cover: string; ep_count: string; id: number; season_url: string; subtitle: string; title: string; view: number }
+1 -2
View File
@@ -93,8 +93,7 @@ function handleQrcodeStatus() {
} }
if (qrcodeStatus.value.code === 0) { if (qrcodeStatus.value.code === 0) {
const sessdata = qrcodeStatus.value.url.split('SESSDATA=')[1].split('&')[0] store.config.sessdata = qrcodeStatus.value.sessdata
store.config.sessdata = encodeURIComponent(sessdata)
showing.value = false showing.value = false
message.success('登录成功') message.success('登录成功')
} }