Skip to main content

ncm_api_rs/api/
comment_video.rs

1use super::Query;
2use crate::error::Result;
3/// 视频评论
4/// 对应 Node.js module/comment_video.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 视频评论
10    /// 对应 /comment/video
11    pub async fn comment_video(&self, query: &Query) -> Result<ApiResponse> {
12        let id = query.get_or("id", "0");
13        let data = json!({
14            "rid": id,
15            "limit": query.get_or("limit", "20").parse::<i64>().unwrap_or(20),
16            "offset": query.get_or("offset", "0").parse::<i64>().unwrap_or(0),
17            "beforeTime": query.get_or("before", "0").parse::<i64>().unwrap_or(0)
18        });
19        self.request(
20            &format!("/api/v1/resource/comments/R_VI_62_{}", id),
21            data,
22            query.to_option(CryptoType::Weapi),
23        )
24        .await
25    }
26}