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
25 .post("https://api.bilibili.com/x/dynamic/feed/operate/remove")
26 .query(&[("csrf", csrf)])
27 .json(&json!({
28 "dyn_id_str": dyn_id
29 }))
30 .send_bpi("删除动态").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
49 .post("https://member.bilibili.com/x/web/article/delete")
50 .form(
51 &[
52 ("aid", aid.to_string()),
53 ("csrf", csrf),
54 ]
55 )
56 .send_bpi("删除专栏").await
57 }
58}
59
60#[cfg(test)]
61mod tests {
62 use super::*;
63
64 const TEST_DYN_ID: &str = "951560312615600129";
65 const TEST_AID: u64 = 42997969;
66
67 #[ignore]
68 #[tokio::test]
69 async fn test_dynamic_delete() -> Result<(), Box<BpiError>> {
70 let bpi = BpiClient::new();
71
72 bpi.dynamic_delete(TEST_DYN_ID).await?;
73
74 Ok(())
75 }
76 #[ignore]
77 #[tokio::test]
78 async fn test_article_delete() -> Result<(), Box<BpiError>> {
79 let bpi = BpiClient::new();
80
81 bpi.article_delete(TEST_AID).await?;
82
83 Ok(())
84 }
85}