ncm_api_rs/api/
search_match.rs1use super::Query;
2use crate::error::Result;
3use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9 pub async fn search_match(&self, query: &Query) -> Result<ApiResponse> {
12 let songs = json!([{
13 "title": query.get_or("title", ""),
14 "album": query.get_or("album", ""),
15 "artist": query.get_or("artist", ""),
16 "duration": query.get_or("duration", "0").parse::<i64>().unwrap_or(0),
17 "persistId": query.get_or("md5", ""),
18 }]);
19 let data = json!({
20 "songs": songs.to_string(),
21 });
22 self.request(
23 "/api/search/match/new",
24 data,
25 query.to_option(CryptoType::default()),
26 )
27 .await
28 }
29}