Crates.io | kodik-api |
lib.rs | kodik-api |
version | |
source | src |
created_at | 2023-07-14 18:33:06.329349 |
updated_at | 2024-11-29 09:50:29.042193 |
description | An unofficial async Rust library that allows you to interact with the Kodik API |
homepage | |
repository | https://github.com/negezor/kodik-api-rust |
max_upload_size | |
id | 916553 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Kodik Rust - An efficient Rust library serving as a wrapper for the Kodik API 🦾
📖 Documentation |
---|
Install kodik from crates.io. Add the following line to your Cargo.toml
file's dependencies section:
kodik-api = "0.3"
Or you can add with cargo
cargo add kodik-api
use kodik_api::Client;
use kodik_api::search::SearchQuery;
#[tokio::main]
async fn main() {
// KODIK_API_KEY=q8p5vnf9crt7xfyzke4iwc6r5rvsurv7
let api_key = std::env::var("KODIK_API_KEY").expect("KODIK_API_KEY is not set");
let client = Client::new(api_key);
let search_response = SearchQuery::new()
.with_title("Cyberpunk: Edgerunners")
.with_limit(1)
.execute(&client)
.await
.unwrap();
println!("search response = {search_response:#?}");
// search response = SearchResponse {
// time: "3ms",
// total: 1,
// prev_page: None,
// next_page: None,
// results: [
// Release {
// id: "serial-45534",
// title: "Киберпанк: Бегущие по краю",
// title_orig: "Cyberpunk: Edgerunners",
// other_title: Some("サイバーパンク エッジランナーズ"),
// link: "//kodik.info/serial/45534/d8619e900d122ea8eff8b55891b09bac/720p",
// year: 2022,
// kinopoisk_id: Some(
// "2000102",
// ),
// imdb_id: Some(
// "tt12590266",
// ),
// mdl_id: None,
// worldart_link: Some(
// "http://www.world-art.ru/animation/animation.php?id=10534",
// ),
// shikimori_id: Some(
// "42310",
// ),
// release_type: AnimeSerial,
// quality: WebDlRip720p,
// camrip: false,
// lgbt: false,
// translation: Translation {
// id: 610,
// title: "AniLibria.TV",
// translation_type: Voice,
// },
// created_at: "2022-09-14T10:54:34Z",
// updated_at: "2022-09-23T22:31:33Z",
// blocked_seasons: Some(
// {},
// ),
// seasons: None,
// last_season: Some(
// 1,
// ),
// last_episode: Some(
// 10,
// ),
// episodes_count: Some(
// 10,
// ),
// blocked_countries: [],
// material_data: None,
// screenshots: [
// "https://i.kodik.biz/screenshots/seria/104981222/1.jpg",
// "https://i.kodik.biz/screenshots/seria/104981222/2.jpg",
// "https://i.kodik.biz/screenshots/seria/104981222/3.jpg",
// "https://i.kodik.biz/screenshots/seria/104981222/4.jpg",
// "https://i.kodik.biz/screenshots/seria/104981222/5.jpg",
// ],
// },
// ],
// }
}
use futures_util::{pin_mut, StreamExt};
use kodik_api::Client;
use kodik_api::list::ListQuery;
use kodik_api::types::ReleaseType;
#[tokio::main]
async fn main() {
// KODIK_API_KEY=q8p5vnf9crt7xfyzke4iwc6r5rvsurv7
let api_key = std::env::var("KODIK_API_KEY").expect("KODIK_API_KEY is not set");
let client = Client::new(api_key);
let stream = ListQuery::new()
.with_limit(100)
.with_types(&[ReleaseType::Anime, ReleaseType::AnimeSerial])
.stream(&client);
pin_mut!(stream);
while let Some(response) = stream.next().await {
match response {
Ok(response) => {
dbg!(response.total);
dbg!(response.results);
}
Err(err) => {
match err {
// Kodik error
kodik_api::error::Error::KodikError(message) => {
panic!("kodik error = {}", message);
}
// Reqwest error
kodik_api::error::Error::HttpError(_err) => {
// Another try
continue;
}
_ => {
panic!("Unknown error")
}
}
}
}
}
}