| Crates.io | dandanapi |
| lib.rs | dandanapi |
| version | 0.0.1 |
| created_at | 2025-06-19 05:22:03.878416+00 |
| updated_at | 2025-06-19 05:22:03.878416+00 |
| description | Dandanapi http client |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1717836 |
| size | 87,003 |
This lib currently only serves the Tsukimi application. So its completeness is very low.
You shold use the SecretGenerator to generate a token for your application.
We use the ed25519/X25519 algorithm to sign the token.
use dandanapi::{
Comments,
Episodes,
SecretGenerator,
};
const X_APPID: &str = "e9imrhcexn";
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let key = include_str!("../ed25519_key");
let ciphertext = include_bytes!("../secret");
let generator = SecretGenerator::new(ciphertext.to_vec(), key.to_string());
dandanapi::DanDanClient::init(X_APPID.to_string(), generator).unwrap();
let client = dandanapi::DanDanClient::instance();
let route = client.route(Episodes(dandanapi::RequestEpisodes {
anime: "夏日口袋".to_string(),
tmdb_id: Some(271576),
episode: "度过暑假的方法".to_string(),
}));
let response = route.await.unwrap();
let episode_id = response
.animes
.unwrap()
.first()
.unwrap()
.episodes
.first()
.unwrap()
.episode_id;
let route = client.route(Comments {
episode_id,
request_comments: dandanapi::RequestComments {
from: 0,
with_related: true,
ch_convert: dandanapi::ChConvert::NONE,
},
});
let response = route.await.unwrap();
dbg!(response);
Ok(())
}
The API structure is very scalable.
So add requests like this:
pub struct Comments {
pub episode_id: i64,
pub request_comments: RequestComments,
}
impl Request for Comments {
type Response = CommentResponse;
type Body = ();
type Params = RequestComments;
const PATH: &'static str = "/api/v2/comment";
fn params(&self) -> Option<&Self::Params> {
Some(&self.request_comments)
}
fn path(&self) -> Cow<'static, str> {
Cow::Owned(format!("{}/{}", Self::PATH, self.episode_id))
}
}
This project is licensed under the MIT License. See the LICENSE file for details.