Skip to main content

ncm_api_rs/api/
artist_sub.rs

1use super::Query;
2use crate::error::Result;
3/// 收藏/取消收藏歌手
4/// 对应 Node.js module/artist_sub.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 收藏/取消收藏歌手
10    /// 对应 /artist/sub
11    pub async fn artist_sub(&self, query: &Query) -> Result<ApiResponse> {
12        let t = query.get_or("t", "1");
13        let path = if t == "1" { "sub" } else { "unsub" };
14        let id = query.get_or("id", "0");
15        let data = json!({
16            "artistId": id,
17            "artistIds": format!("[{}]", id)
18        });
19        self.request(
20            &format!("/api/artist/{}", path),
21            data,
22            query.to_option(CryptoType::Weapi),
23        )
24        .await
25    }
26}