bpi_rs/danmaku/
snapshot.rs1use crate::{ BilibiliRequest, BpiClient, BpiError, BpiResponse };
6
7pub type SnapshotResponse = BpiResponse<Vec<String>>;
8
9impl BpiClient {
10 pub async fn danmaku_snapshot(&self, aid_or_bvid: &str) -> Result<SnapshotResponse, BpiError> {
21 let resp: SnapshotResponse = self
22 .get("https://api.bilibili.com/x/v2/dm/ajax")
23 .query(&[("aid", aid_or_bvid.to_string())])
24 .send_bpi("获取弹幕快照").await?;
25
26 Ok(resp)
27 }
28}
29
30#[cfg(test)]
31pub mod tests {
32 use super::*;
33
34 #[tokio::test]
35 async fn test_get_danmaku_snapshot() -> Result<(), Box<BpiError>> {
36 let bpi = BpiClient::new();
37 let result = bpi.danmaku_snapshot("BV1fK4y1t741").await?;
38
39 let data = result.into_data()?;
40 tracing::info!("{:#?}", data);
41
42 Ok(())
43 }
44}