ncm_api_rs/api/
artist_list.rs1use super::Query;
2use crate::error::Result;
3use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9 pub async fn artist_list(&self, query: &Query) -> Result<ApiResponse> {
12 let initial_str = query.get_or("initial", "");
13 let initial = if initial_str.is_empty() {
14 serde_json::Value::Null
15 } else if let Ok(n) = initial_str.parse::<i64>() {
16 json!(n)
17 } else {
18 let ch = initial_str.to_uppercase().chars().next().unwrap_or('A');
19 json!(ch as i64)
20 };
21 let data = json!({
22 "initial": initial,
23 "offset": query.get_or("offset", "0").parse::<i64>().unwrap_or(0),
24 "limit": query.get_or("limit", "30").parse::<i64>().unwrap_or(30),
25 "total": true,
26 "type": query.get_or("type", "1"),
27 "area": query.get_or("area", "")
28 });
29 self.request(
30 "/api/v1/artist/list",
31 data,
32 query.to_option(CryptoType::Weapi),
33 )
34 .await
35 }
36}