Skip to main content

ncm_api_rs/api/
album_sub.rs

1use super::Query;
2use crate::error::Result;
3/// 收藏/取消收藏专辑
4/// 对应 Node.js module/album_sub.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 收藏/取消收藏专辑
10    /// 对应 /album/sub
11    pub async fn album_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 data = json!({
15            "id": query.get_or("id", "0")
16        });
17        self.request(
18            &format!("/api/album/{}", path),
19            data,
20            query.to_option(CryptoType::Weapi),
21        )
22        .await
23    }
24}