fix: 修复类型错误导致的数值溢出 (#115)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2024-06-01 03:21:23 +08:00
committed by GitHub
parent 2ef99a20c9
commit c4db12b154
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
pub id: i32, pub id: i32,
pub video_id: i32, pub video_id: i32,
pub cid: i32, pub cid: i64,
pub pid: i32, pub pid: i32,
pub name: String, pub name: String,
pub width: Option<u32>, pub width: Option<u32>,
+3 -3
View File
@@ -39,7 +39,7 @@ impl serde::Serialize for Tag {
} }
#[derive(Debug, serde::Deserialize, Default)] #[derive(Debug, serde::Deserialize, Default)]
pub struct PageInfo { pub struct PageInfo {
pub cid: i32, pub cid: i64,
pub page: i32, pub page: i32,
#[serde(rename = "part")] #[serde(rename = "part")]
pub name: String, pub name: String,
@@ -92,7 +92,7 @@ impl<'a> Video<'a> {
pub async fn get_danmaku_writer(&self, page: &'a PageInfo) -> Result<DanmakuWriter> { pub async fn get_danmaku_writer(&self, page: &'a PageInfo) -> Result<DanmakuWriter> {
let tasks = FuturesUnordered::new(); let tasks = FuturesUnordered::new();
for i in 1..=(page.duration + 359) / 360 { for i in 1..=(page.duration + 359) / 360 {
tasks.push(self.get_danmaku_segment(page, i as i32)); tasks.push(self.get_danmaku_segment(page, i as i64));
} }
let result: Vec<Vec<DanmakuElem>> = tasks.try_collect().await?; let result: Vec<Vec<DanmakuElem>> = tasks.try_collect().await?;
let mut result: Vec<DanmakuElem> = result.into_iter().flatten().collect(); let mut result: Vec<DanmakuElem> = result.into_iter().flatten().collect();
@@ -100,7 +100,7 @@ impl<'a> Video<'a> {
Ok(DanmakuWriter::new(page, result.into_iter().map(|x| x.into()).collect())) Ok(DanmakuWriter::new(page, result.into_iter().map(|x| x.into()).collect()))
} }
async fn get_danmaku_segment(&self, page: &PageInfo, segment_idx: i32) -> Result<Vec<DanmakuElem>> { async fn get_danmaku_segment(&self, page: &PageInfo, segment_idx: i64) -> Result<Vec<DanmakuElem>> {
let mut res = self let mut res = self
.client .client
.request(Method::GET, "http://api.bilibili.com/x/v2/dm/web/seg.so") .request(Method::GET, "http://api.bilibili.com/x/v2/dm/web/seg.so")