mirror of
https://github.com/lanyeeee/bilibili-video-downloader.git
synced 2026-09-05 23:57:23 +08:00
@@ -120,6 +120,15 @@ impl BiliClient {
|
||||
let http_resp = request.send().await?;
|
||||
// 检查http响应状态码
|
||||
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?;
|
||||
if status != StatusCode::OK {
|
||||
return Err(eyre!("预料之外的状态码({status}): {body}"));
|
||||
@@ -137,11 +146,14 @@ impl BiliClient {
|
||||
};
|
||||
// 尝试将data解析为二维码状态
|
||||
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}"))?;
|
||||
if ![0, 86101, 86090, 86038].contains(&qrcode_status.code) {
|
||||
return Err(eyre!("预料之外的二维码code: {qrcode_status:?}"));
|
||||
}
|
||||
if qrcode_status.code == 0 {
|
||||
qrcode_status.sessdata = sessdata.ok_or_eyre("扫码成功,但没有解析到SESSDATA")?;
|
||||
}
|
||||
Ok(qrcode_status)
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ impl ChapterSegments {
|
||||
// 遍历完所有现有片段并处理完所有重叠后,将新的片段添加到结果列表中
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use specta::Type;
|
||||
#[serde(default)]
|
||||
pub struct QrcodeStatus {
|
||||
pub url: String,
|
||||
pub sessdata: String,
|
||||
pub refresh_token: String,
|
||||
pub timestamp: i64,
|
||||
pub code: i64,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "bilibili-video-downloader",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"identifier": "com.lanyeeee.bilibili-video-downloader",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
|
||||
+1
-1
@@ -424,7 +424,7 @@ export type PurchaseFormatNote = { content_list: ContentList[]; link: string; ti
|
||||
export type PurchaseNote = { content: string; link: string; title: string }
|
||||
export type PurchaseProtocol = { link: string; title: 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 RatingInBangumiFollow = { score: number; count: number }
|
||||
export type RecommendSeason = { cover: string; ep_count: string; id: number; season_url: string; subtitle: string; title: string; view: number }
|
||||
|
||||
@@ -93,8 +93,7 @@ function handleQrcodeStatus() {
|
||||
}
|
||||
|
||||
if (qrcodeStatus.value.code === 0) {
|
||||
const sessdata = qrcodeStatus.value.url.split('SESSDATA=')[1].split('&')[0]
|
||||
store.config.sessdata = encodeURIComponent(sessdata)
|
||||
store.config.sessdata = qrcodeStatus.value.sessdata
|
||||
showing.value = false
|
||||
message.success('登录成功')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user