Skip to main content

ncm_api_rs/api/
top_album.rs

1use super::Query;
2use crate::error::Result;
3/// 新碟上架
4/// 对应 Node.js module/top_album.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 新碟上架
10    /// 对应 /top/album
11    pub async fn top_album(&self, query: &Query) -> Result<ApiResponse> {
12        let now = chrono::Utc::now();
13        let data = json!({
14            "area": query.get_or("area", "ALL"),
15            "limit": query.get_or("limit", "50").parse::<i64>().unwrap_or(50),
16            "offset": query.get_or("offset", "0").parse::<i64>().unwrap_or(0),
17            "type": query.get_or("type", "new"),
18            "year": query.get_or("year", &now.format("%Y").to_string()),
19            "month": query.get_or("month", &now.format("%-m").to_string()),
20            "total": false,
21            "rcmd": true
22        });
23        self.request(
24            "/api/discovery/new/albums/area",
25            data,
26            query.to_option(CryptoType::Weapi),
27        )
28        .await
29    }
30}