tmdb_rs/endpoints/
find.rs1use serde::Deserialize;
2use strum::Display;
3use time::Date;
4
5use crate::endpoints::movie::MovieShort;
6use crate::endpoints::person::PersonShort;
7use crate::endpoints::tv::TvShort;
8use crate::{Language, Poster, Still};
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Display)]
12pub enum ExternalSource {
13 #[strum(serialize = "imdb_id")]
14 Imdb,
15 #[strum(serialize = "tvdb_id")]
16 Tvdb,
17 #[strum(serialize = "facebook_id")]
18 Facebook,
19 #[strum(serialize = "instagram_id")]
20 Instagram,
21 #[strum(serialize = "threads_id")]
22 Threads,
23 #[strum(serialize = "tiktok_id")]
24 Tiktok,
25 #[strum(serialize = "twitter_id")]
26 Twitter,
27 #[strum(serialize = "wikidata_id")]
28 Wikidata,
29 #[strum(serialize = "youtube_id")]
30 Youtube,
31}
32
33#[derive(Debug, Clone, Deserialize)]
35pub struct FoundSeason {
36 pub id: u64,
37 pub show_id: u64,
38 pub name: String,
39 pub season_number: u32,
40 #[serde(default, deserialize_with = "crate::common::opt_date")]
41 pub air_date: Option<Date>,
42 #[serde(rename = "poster_path")]
43 pub poster: Option<Poster>,
44}
45
46#[derive(Debug, Clone, Deserialize)]
48pub struct FoundEpisode {
49 pub id: u64,
50 pub show_id: u64,
51 pub name: String,
52 pub episode_number: u32,
53 pub season_number: u32,
54 #[serde(default, deserialize_with = "crate::common::opt_date")]
55 pub air_date: Option<Date>,
56 #[serde(rename = "still_path")]
57 pub still: Option<Still>,
58 pub vote_average: f64,
59 pub vote_count: u32,
60}
61
62#[derive(Debug, Clone, Default, Deserialize)]
64#[serde(default)]
65pub struct FindResults {
66 pub movie_results: Vec<MovieShort>,
67 pub tv_results: Vec<TvShort>,
68 pub person_results: Vec<PersonShort>,
69 pub tv_episode_results: Vec<FoundEpisode>,
70 pub tv_season_results: Vec<FoundSeason>,
71}
72
73endpoint! {
74 find(external_id: &str, external_source: ExternalSource): GET "/find/{external_id}" => FindResults {
76 params { language: Language }
77 }
78}