Skip to main content

ncm_api_rs/api/
dj_toplist.rs

1use super::Query;
2use crate::error::Result;
3/// 电台排行榜
4/// 对应 Node.js module/dj_toplist.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 电台排行榜
10    /// 对应 /dj/toplist
11    pub async fn dj_toplist(&self, query: &Query) -> Result<ApiResponse> {
12        let type_val = query.get_or("type", "new");
13        let type_id = match type_val.as_str() {
14            "hot" => 1,
15            _ => 0,
16        };
17        let data = json!({
18            "limit": query.get_or("limit", "100").parse::<i64>().unwrap_or(100),
19            "offset": query.get_or("offset", "0").parse::<i64>().unwrap_or(0),
20            "type": type_id
21        });
22        self.request(
23            "/api/djradio/toplist",
24            data,
25            query.to_option(CryptoType::Weapi),
26        )
27        .await
28    }
29}