Skip to main content

bpi_rs/user/relation/
following_group.rs

1//! B站用户关注分组相关接口
2//!
3//! [查看 API 文档](https://github.com/SocialSisterYi/bilibili-API-collect/tree/master/docs/user)
4use crate::{ BilibiliRequest, BpiClient, BpiError, BpiResponse };
5use serde::{ Deserialize, Serialize };
6
7/// 关注分组
8#[derive(Debug, Clone, Deserialize, Serialize)]
9pub struct FollowTag {
10    pub tagid: i64, // 分组 id (-10: 特别关注, 0: 默认分组)
11    pub name: String, // 分组名称
12    pub count: i64, // 分组成员数
13    pub tip: Option<String>, // 提示信息
14}
15
16impl BpiClient {
17    /// 查询关注分组列表
18    ///
19    /// # 文档
20    /// [查看API文档](https://github.com/SocialSisterYi/bilibili-API-collect/tree/master/docs/user)
21    pub async fn user_follow_tags(&self) -> Result<BpiResponse<Vec<FollowTag>>, BpiError> {
22        self.get("https://api.bilibili.com/x/relation/tags").send_bpi("查询关注分组列表").await
23    }
24}
25
26#[cfg(test)]
27mod tests {
28    use super::*;
29    use tracing::info;
30
31    #[tokio::test]
32    async fn test_user_follow_tags_cookie() {
33        let bpi = BpiClient::new();
34        let resp = bpi.user_follow_tags().await;
35        assert!(resp.is_ok());
36
37        let data = resp.unwrap().data.unwrap();
38        info!("关注分组列表: {:?}", data);
39    }
40}