bpi_rs/user/relation/
following_group.rs

1//! B站用户关注分组相关接口
2//!
3//! 文档: 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    /// 文档: https://github.com/SocialSisterYi/bilibili-API-collect/tree/master/docs/user
20    pub async fn user_follow_tags(&self) -> Result<BpiResponse<Vec<FollowTag>>, BpiError> {
21        self.get("https://api.bilibili.com/x/relation/tags")
22            .send_bpi("查询关注分组列表")
23            .await
24    }
25}
26
27#[cfg(test)]
28mod tests {
29    use super::*;
30    use tracing::info;
31
32    #[tokio::test]
33    async fn test_user_follow_tags_cookie() {
34        let bpi = BpiClient::new();
35        let resp = bpi.user_follow_tags().await;
36        assert!(resp.is_ok());
37
38        let data = resp.unwrap().data.unwrap();
39        info!("关注分组列表: {:?}", data);
40    }
41}