1#[cfg(feature = "commands")]
2pub mod alternative_titles;
3#[cfg(feature = "commands")]
4pub mod changes;
5#[cfg(feature = "commands")]
6pub mod credits;
7#[cfg(feature = "commands")]
8pub mod details;
9#[cfg(feature = "commands")]
10pub mod external_ids;
11#[cfg(feature = "commands")]
12pub mod images;
13#[cfg(feature = "commands")]
14pub mod keywords;
15#[cfg(feature = "commands")]
16pub mod latest;
17#[cfg(feature = "commands")]
18pub mod lists;
19#[cfg(feature = "commands")]
20pub mod now_playing;
21#[cfg(feature = "commands")]
22pub mod popular;
23#[cfg(feature = "commands")]
24pub mod recommendations;
25#[cfg(feature = "commands")]
26pub mod release_dates;
27#[cfg(feature = "commands")]
28pub mod reviews;
29#[cfg(feature = "commands")]
30pub mod search;
31#[cfg(feature = "commands")]
32pub mod similar;
33#[cfg(feature = "commands")]
34pub mod top_rated;
35#[cfg(feature = "commands")]
36pub mod translations;
37#[cfg(feature = "commands")]
38pub mod upcoming;
39#[cfg(feature = "commands")]
40pub mod videos;
41#[cfg(feature = "commands")]
42pub mod watch_providers;
43
44use crate::collection::CollectionBase;
45use crate::common::country::Country;
46use crate::common::language::Language;
47use crate::common::status::Status;
48use crate::company::CompanyShort;
49use crate::genre::Genre;
50
51#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
52pub struct MovieBase {
53 pub id: u64,
54 pub title: String,
55 pub original_title: String,
56 pub original_language: String,
57 pub overview: String,
58 #[serde(default, deserialize_with = "crate::util::empty_string::deserialize")]
59 pub release_date: Option<chrono::NaiveDate>,
60 pub poster_path: Option<String>,
61 pub backdrop_path: Option<String>,
62 pub adult: bool,
63 pub popularity: f64,
64 pub vote_count: u64,
65 pub vote_average: f64,
66 pub video: bool,
67}
68
69#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
70pub struct MovieShort {
71 #[serde(flatten)]
72 pub inner: MovieBase,
73 pub genre_ids: Vec<u64>,
74}
75
76#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
77pub struct Movie {
78 #[serde(flatten)]
79 pub inner: MovieBase,
80 pub budget: u64,
81 pub genres: Vec<Genre>,
82 #[serde(deserialize_with = "crate::util::empty_string::deserialize")]
83 pub homepage: Option<String>,
84 #[serde(deserialize_with = "crate::util::empty_string::deserialize")]
85 pub imdb_id: Option<String>,
86 pub belongs_to_collection: Option<CollectionBase>,
87 pub production_companies: Vec<CompanyShort>,
88 pub production_countries: Vec<Country>,
89 pub revenue: u64,
90 pub runtime: Option<u64>,
91 pub spoken_languages: Vec<Language>,
92 pub status: Status,
93 pub tagline: Option<String>,
94}
95
96#[cfg(test)]
97mod tests {
98
99 #[test]
100 fn serialize() {
101 let origin = include_str!("../../assets/movie-details.json");
102 let movie: super::Movie = serde_json::from_str(origin).unwrap();
103 let serial = serde_json::to_string_pretty(&movie).unwrap();
104 println!("serial: {}", serial);
105 let expected: super::Movie = serde_json::from_str(&serial).unwrap();
106 assert_eq!(movie, expected);
107 }
108}