bpi_rs/creativecenter/
opus.rs1use crate::{BilibiliRequest, BpiClient, BpiError, BpiResponse};
6use serde_json::json;
7
8impl BpiClient {
9 pub async fn dynamic_delete(
19 &self,
20 dyn_id: &str,
21 ) -> Result<BpiResponse<serde_json::Value>, BpiError> {
22 let csrf = self.csrf()?;
23
24 self.post("https://api.bilibili.com/x/dynamic/feed/operate/remove")
25 .query(&[("csrf", csrf)])
26 .json(&json!({
27 "dyn_id_str": dyn_id
28 }))
29 .send_bpi("删除动态")
30 .await
31 }
32
33 pub async fn article_delete(
43 &self,
44 aid: u64,
45 ) -> Result<BpiResponse<serde_json::Value>, BpiError> {
46 let csrf = self.csrf()?;
47
48 self.post("https://member.bilibili.com/x/web/article/delete")
49 .form(&[("aid", aid.to_string()), ("csrf", csrf)])
50 .send_bpi("删除专栏")
51 .await
52 }
53}
54
55#[cfg(test)]
56mod tests {
57 use super::*;
58
59 const TEST_DYN_ID: &str = "951560312615600129";
60 const TEST_AID: u64 = 42997969;
61
62 #[ignore]
63 #[tokio::test]
64 async fn test_dynamic_delete() -> Result<(), Box<BpiError>> {
65 let bpi = BpiClient::new();
66
67 bpi.dynamic_delete(TEST_DYN_ID).await?;
68
69 Ok(())
70 }
71 #[ignore]
72 #[tokio::test]
73 async fn test_article_delete() -> Result<(), Box<BpiError>> {
74 let bpi = BpiClient::new();
75
76 bpi.article_delete(TEST_AID).await?;
77
78 Ok(())
79 }
80}