1use serde::{ Deserialize, Serialize };
2
3use crate::{ BilibiliRequest, BpiClient, BpiError, BpiResponse };
4
5#[derive(Debug, Serialize, Clone, Deserialize)]
8pub struct LiveSubArea {
9 pub id: String,
11 pub parent_id: String,
13 pub old_area_id: String,
15 pub name: String,
17 pub act_id: String,
19 pub pk_status: String,
21 pub hot_status: i32,
23 pub lock_status: String,
25 pub pic: String,
27 pub parent_name: String,
29 pub area_type: i32,
31}
32
33#[derive(Debug, Serialize, Clone, Deserialize)]
34pub struct LiveParentArea {
35 pub id: i32,
37 pub name: String,
39 pub list: Vec<LiveSubArea>,
41}
42
43impl BpiClient {
44 pub async fn live_area_list(&self) -> Result<BpiResponse<Vec<LiveParentArea>>, BpiError> {
50 let resp = self
51 .get("https://api.live.bilibili.com/room/v1/Area/getList")
52 .send_bpi("获取全部直播间分区列表").await?;
53
54 Ok(resp)
55 }
56}
57
58#[cfg(test)]
59mod tests {
60 use super::*;
61
62 #[tokio::test]
63 async fn test_get_live_area_list() -> Result<(), Box<BpiError>> {
64 let bpi = BpiClient::new();
65 let resp = bpi.live_area_list().await?;
66
67 let data = resp.data.unwrap();
68 assert!(data.len() > 0);
69 Ok(())
70 }
71}