bpi_rs/danmaku/
history.rs1use crate::{BilibiliRequest, BpiClient, BpiError, BpiResponse};
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct HistoryDatesResponseData(Vec<String>);
10
11pub type HistoryDatesResponse = BpiResponse<Vec<String>>;
12
13impl BpiClient {
14 pub async fn danmaku_history_dates(
25 &self,
26 oid: i64,
27 month: &str,
28 ) -> Result<HistoryDatesResponse, BpiError> {
29 let params = vec![
30 ("type", "1".to_string()),
31 ("oid", oid.to_string()),
32 ("month", month.to_string()),
33 ];
34
35 let resp: HistoryDatesResponse = self
36 .get("https://api.bilibili.com/x/v2/dm/history/index")
37 .query(¶ms)
38 .send_bpi("查询历史弹幕日期")
39 .await?;
40
41 Ok(resp)
42 }
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[tokio::test]
50 async fn test_get_history_dates() -> Result<(), Box<BpiError>> {
51 let bpi = BpiClient::new();
52 let result = bpi.danmaku_history_dates(144541892, "2022-01").await?;
53 let data = result.into_data()?;
54 tracing::info!("{:#?}", data);
55
56 Ok(())
57 }
58}