Skip to content

Commit

Permalink
fix: 修复类型错误导致的数值溢出 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoaer committed May 31, 2024
1 parent 2ef99a2 commit c4db12b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion entity/src/entities/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down
6 changes: 3 additions & 3 deletions src/bilibili/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -92,15 +92,15 @@ 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();
result.sort_by_key(|d| d.progress);
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")
Expand Down

0 comments on commit c4db12b

Please sign in to comment.