Skip to main content

Filters

Struct Filters 

Source
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>§mydramalist_tags: Vec<String>§mydramalist_tags_and: 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

Source

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
Hide additional 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}
Source

pub fn with_countries( self, values: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Добавляет фильтр по странам с семантикой «хотя бы одна».

Source

pub fn with_genres( self, values: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Добавляет фильтр по жанрам КиноПоиска с семантикой «хотя бы один».

Trait Implementations§

Source§

impl Clone for Filters

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Filters

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Filters

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Filters

Source§

impl PartialEq for Filters

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Filters

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more