Skip to main content

ncm_api_rs/api/
album_songsaleboard.rs

1use super::Query;
2use crate::error::Result;
3/// 数字专辑&数字单曲-榜单
4/// 对应 Node.js module/album_songsaleboard.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 数字专辑&数字单曲-榜单
10    /// 对应 /album/songsaleboard
11    pub async fn album_songsaleboard(&self, query: &Query) -> Result<ApiResponse> {
12        let album_type = query.get_or("albumType", "0");
13        let sale_type = query.get_or("type", "daily");
14
15        let mut data = json!({
16            "albumType": album_type.parse::<i64>().unwrap_or(0)
17        });
18
19        if sale_type == "year" {
20            data["year"] = json!(query.get_or("year", ""));
21        }
22
23        let url = format!("/api/feealbum/songsaleboard/{}/type", sale_type);
24        self.request(&url, data, query.to_option(CryptoType::Weapi))
25            .await
26    }
27}