feat: 尽量将用户可见日志替换成中文,修复部分问题
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//! 一个弹幕实例,但是没有位置信息
|
||||
use anyhow::Result;
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
use super::canvas::CanvasConfig;
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
@@ -18,7 +18,8 @@ impl DanmuType {
|
||||
4 => DanmuType::Bottom,
|
||||
5 => DanmuType::Top,
|
||||
6 => DanmuType::Reverse,
|
||||
_ => unreachable!(),
|
||||
// 高级弹幕、代码弹幕等,不支持,这里 return error,外面 unwrap_or_default 当成 Float 处理
|
||||
_ => bail!("UnSupported danmu type"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ impl<'a> FavoriteList<'a> {
|
||||
},
|
||||
};
|
||||
if !videos["data"]["medias"].is_array() {
|
||||
error!("no medias found in favorite {} page {}", self.fid, page);
|
||||
warn!("no medias found in favorite {} page {}", self.fid, page);
|
||||
break;
|
||||
}
|
||||
let videos_info = match serde_json::from_value::<Vec<VideoInfo>>(videos["data"]["medias"].take()) {
|
||||
|
||||
@@ -114,16 +114,23 @@ impl<'a> Video<'a> {
|
||||
}
|
||||
|
||||
async fn get_danmaku_segment(&self, page: &PageInfo, segment_idx: i32) -> Result<Vec<DanmakuElem>> {
|
||||
let res = self
|
||||
let mut res = self
|
||||
.client
|
||||
.request(Method::GET, "http://api.bilibili.com/x/v2/dm/web/seg.so")
|
||||
.query(&[("type", 1), ("oid", page.cid), ("segment_index", segment_idx)])
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.bytes()
|
||||
.await?;
|
||||
Ok(DmSegMobileReply::decode(res)?.elems)
|
||||
.error_for_status()?;
|
||||
let headers = std::mem::take(res.headers_mut());
|
||||
let content_type = headers.get("content-type");
|
||||
if !content_type.is_some_and(|v| v == "application/octet-stream") {
|
||||
bail!(
|
||||
"unexpected content type: {:?}, body: {:?}",
|
||||
content_type,
|
||||
res.text().await
|
||||
);
|
||||
}
|
||||
Ok(DmSegMobileReply::decode(res.bytes().await?)?.elems)
|
||||
}
|
||||
|
||||
pub async fn get_page_analyzer(&self, page: &PageInfo) -> Result<PageAnalyzer> {
|
||||
|
||||
Reference in New Issue
Block a user