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(
26 &self,
27 oid: i64,
28 month: &str
29 ) -> Result<HistoryDatesResponse, BpiError> {
30 let params = vec![
31 ("type", "1".to_string()),
32 ("oid", oid.to_string()),
33 ("month", month.to_string())
34 ];
35
36 let resp: HistoryDatesResponse = self
37 .get("https://api.bilibili.com/x/v2/dm/history/index")
38 .query(¶ms)
39 .send_bpi("查询历史弹幕日期").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}