pub struct Filters {Show 52 fields
pub types: Vec<ContentType>,
pub year: Vec<i32>,
pub translation_ids: Vec<u64>,
pub block_translations: Vec<u64>,
pub translation_type: Option<TranslationType>,
pub has_field: Vec<RequiredField>,
pub has_field_and: Vec<RequiredField>,
pub camrip: Option<bool>,
pub lgbt: Option<bool>,
pub countries: Vec<String>,
pub countries_and: Vec<String>,
pub genres: Vec<String>,
pub genres_and: Vec<String>,
pub anime_genres: Vec<String>,
pub anime_genres_and: Vec<String>,
pub drama_genres: Vec<String>,
pub drama_genres_and: Vec<String>,
pub all_genres: Vec<String>,
pub all_genres_and: Vec<String>,
pub duration: Option<String>,
pub kinopoisk_rating: Option<String>,
pub imdb_rating: Option<String>,
pub shikimori_rating: Option<String>,
pub mydramalist_rating: Option<String>,
pub actors: Vec<String>,
pub actors_and: Vec<String>,
pub directors: Vec<String>,
pub directors_and: Vec<String>,
pub producers: Vec<String>,
pub producers_and: Vec<String>,
pub writers: Vec<String>,
pub writers_and: Vec<String>,
pub composers: Vec<String>,
pub composers_and: Vec<String>,
pub editors: Vec<String>,
pub editors_and: Vec<String>,
pub designers: Vec<String>,
pub designers_and: Vec<String>,
pub operators: Vec<String>,
pub operators_and: Vec<String>,
pub rating_mpaa: Vec<String>,
pub minimal_age: Option<String>,
pub anime_kind: Vec<String>,
pub mydramalist_tags: Vec<String>,
pub mydramalist_tags_and: Vec<String>,
pub anime_status: Vec<String>,
pub drama_status: Vec<String>,
pub all_status: Vec<String>,
pub anime_studios: Vec<String>,
pub anime_studios_and: Vec<String>,
pub anime_licensed_by: Vec<String>,
pub anime_licensed_by_and: Vec<String>,
}Expand description
Общие фильтры материалов, доступные в /years, /genres, /countries,
/qualities/v2, /translations/v2, /list и /search.
Поля с суффиксом _and требуют наличия всех перечисленных значений.
Их аналоги без суффикса используют семантику «хотя бы одно». Диапазоны
(duration, рейтинги и minimal_age) нужно задавать строкой: "40-80".
Fields§
§types: Vec<ContentType>§year: Vec<i32>§translation_ids: Vec<u64>§block_translations: Vec<u64>§translation_type: Option<TranslationType>§has_field: Vec<RequiredField>§has_field_and: Vec<RequiredField>§camrip: Option<bool>§lgbt: Option<bool>§countries: Vec<String>§countries_and: Vec<String>§genres: Vec<String>§genres_and: Vec<String>§anime_genres: Vec<String>§anime_genres_and: Vec<String>§drama_genres: Vec<String>§drama_genres_and: Vec<String>§all_genres: Vec<String>§all_genres_and: Vec<String>§duration: Option<String>§kinopoisk_rating: Option<String>§imdb_rating: Option<String>§shikimori_rating: Option<String>§mydramalist_rating: Option<String>§actors: Vec<String>§actors_and: Vec<String>§directors: Vec<String>§directors_and: Vec<String>§producers: Vec<String>§producers_and: Vec<String>§writers: Vec<String>§writers_and: Vec<String>§composers: Vec<String>§composers_and: Vec<String>§editors: Vec<String>§editors_and: Vec<String>§designers: Vec<String>§designers_and: Vec<String>§operators: Vec<String>§operators_and: Vec<String>§rating_mpaa: Vec<String>§minimal_age: Option<String>§anime_kind: Vec<String>§anime_status: Vec<String>§drama_status: Vec<String>§all_status: Vec<String>§anime_studios: Vec<String>§anime_studios_and: Vec<String>§anime_licensed_by: Vec<String>§anime_licensed_by_and: Vec<String>Implementations§
Source§impl Filters
impl Filters
Sourcepub fn with_types(self, values: impl IntoIterator<Item = ContentType>) -> Self
pub fn with_types(self, values: impl IntoIterator<Item = ContentType>) -> Self
Добавляет фильтр по типам материалов.
Examples found in repository?
examples/list_all.rs (line 13)
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let token = std::env::var("KODIK_API_TOKEN")
8 .map_err(|_| "set KODIK_API_TOKEN before running this example")?;
9 let client = KodikClient::new(token)?;
10
11 let mut query = ListQuery {
12 limit: Some(100),
13 filters: Filters::default().with_types([ContentType::AnimeSerial]),
14 ..Default::default()
15 };
16
17 let mut page_number = 1_u32;
18 loop {
19 let page: ListResponse = client.list(query.clone()).await?;
20 println!("page {page_number}: {} material(s)", page.results.len());
21 for material in &page.results {
22 println!(" {} — {}", material.id, material.title);
23 }
24
25 let Some(next_page_url) = page.next_page else {
26 break;
27 };
28
29 // Не выполняем URL напрямую: он может содержать query-параметр token.
30 query.next = Some(KodikClient::next_cursor(&next_page_url)?);
31 page_number += 1;
32 }
33
34 Ok(())
35}More examples
examples/search.rs (line 15)
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let token = std::env::var("KODIK_API_TOKEN")
8 .map_err(|_| "set KODIK_API_TOKEN before running this example")?;
9 let client = KodikClient::new(token)?;
10
11 let query = SearchQuery {
12 title: Some("Avatar".into()),
13 full_match: false,
14 limit: Some(10),
15 filters: Filters::default().with_types([ContentType::ForeignMovie]),
16 prioritize_translation_type: Some(TranslationType::Voice),
17 with_material_data: true,
18 ..Default::default()
19 };
20
21 let response = client.search(query).await?;
22 println!("{} result(s), API time: {}", response.total, response.time);
23
24 for material in response.results {
25 let rating = material
26 .material_data
27 .as_ref()
28 .and_then(|data| data.kinopoisk_rating)
29 .map(|value| value.to_string())
30 .unwrap_or_else(|| "n/a".into());
31 println!(
32 "{} | {} | {} | Kinopoisk rating: {rating}",
33 material.id,
34 material
35 .year
36 .map(|year| year.to_string())
37 .unwrap_or_else(|| "n/a".into()),
38 material.title,
39 );
40 }
41
42 Ok(())
43}Sourcepub fn with_countries(
self,
values: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_countries( self, values: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Добавляет фильтр по странам с семантикой «хотя бы одна».
Sourcepub fn with_genres(
self,
values: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_genres( self, values: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Добавляет фильтр по жанрам КиноПоиска с семантикой «хотя бы один».
Trait Implementations§
impl Eq for Filters
impl StructuralPartialEq for Filters
Auto Trait Implementations§
impl Freeze for Filters
impl RefUnwindSafe for Filters
impl Send for Filters
impl Sync for Filters
impl Unpin for Filters
impl UnsafeUnpin for Filters
impl UnwindSafe for Filters
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.