bpi_rs/creativecenter/season/
info.rs1use crate::{ BilibiliRequest, BpiClient, BpiError, BpiResponse };
6use serde::{ Deserialize, Serialize };
7
8use super::models::{ Season, Section };
9
10#[derive(Default, Debug, Clone, Serialize, Deserialize)]
11pub struct SeasonInfoData {
12 pub season: Season,
13 pub course: serde_json::Value,
14 pub checkin: serde_json::Value,
15 #[serde(rename = "seasonStat")]
16 pub season_stat: serde_json::Value,
17 pub sections: Sections,
18 pub part_episodes: serde_json::Value,
19}
20
21#[derive(Default, Debug, Clone, Serialize, Deserialize)]
22pub struct Sections {
23 pub sections: Vec<Section>,
24 pub total: i64,
25}
26
27impl BpiClient {
28 pub async fn season_info(
29 &self,
30 season_id: u64
31 ) -> Result<BpiResponse<SeasonInfoData>, BpiError> {
32 self
33 .get("https://member.bilibili.com/x2/creative/web/season")
34 .query(&[("id", &season_id.to_string())])
35 .send_bpi("获取合集信息").await
36 }
37}
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42
43 const TEST_SSID: u64 = 4294056;
44
45 #[tokio::test]
46 async fn test_season_list() -> Result<(), Box<BpiError>> {
47 let bpi = BpiClient::new();
48 let data = bpi.season_info(TEST_SSID).await?.into_data()?;
49
50 tracing::info!("共 {:?} 个合集", data);
51
52 Ok(())
53 }
54}