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

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2024-05-31 12:21:23 -07:00
committed by GitHub
parent 2ef99a20c9
commit c4db12b154
2 changed files with 4 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub video_id: i32,
pub cid: i32,
pub cid: i64,
pub pid: i32,
pub name: String,
pub width: Option<u32>,

View File

@@ -39,7 +39,7 @@ impl serde::Serialize for Tag {
}
#[derive(Debug, serde::Deserialize, Default)]
pub struct PageInfo {
pub cid: i32,
pub cid: i64,
pub page: i32,
#[serde(rename = "part")]
pub name: String,
@@ -92,7 +92,7 @@ impl<'a> Video<'a> {
pub async fn get_danmaku_writer(&self, page: &'a PageInfo) -> Result<DanmakuWriter> {
let tasks = FuturesUnordered::new();
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 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()))
}
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
.client
.request(Method::GET, "http://api.bilibili.com/x/v2/dm/web/seg.so")