From 9fc65c1d07e41d7ce10cf5c0ed1b25004a01391a Mon Sep 17 00:00:00 2001 From: Evelyn Harthbrooke Date: Wed, 31 Jul 2024 22:48:55 -0600 Subject: [PATCH] commands(tmdb): make some structs private. also shuffle around how the tmdb models are laid out and fix comment spacing. --- src/commands/search/tmdb/mod.rs | 6 +- src/models/tmdb/mod.rs | 121 ++++++++++++++++---------------- 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/src/commands/search/tmdb/mod.rs b/src/commands/search/tmdb/mod.rs index 3335353..609f5b4 100644 --- a/src/commands/search/tmdb/mod.rs +++ b/src/commands/search/tmdb/mod.rs @@ -12,18 +12,18 @@ use serenity::all::{CreateActionRow, CreateButton, CreateEmbed, CreateEmbedFoote use std::time::Duration; #[derive(Deserialize)] -pub struct SearchResponse { +struct SearchResponse { pub results: Vec } #[derive(Deserialize)] -pub struct SearchResult { +struct SearchResult { pub id: u64 } #[derive(Deserialize)] #[rustfmt::skip] -pub struct Collection { +struct Collection { pub name: String, // The name of the collection. pub overview: String, // The overview of the collection. pub poster_path: String, // The poster belonging to the collection. diff --git a/src/models/tmdb/mod.rs b/src/models/tmdb/mod.rs index 771dfbf..0d8b6c4 100644 --- a/src/models/tmdb/mod.rs +++ b/src/models/tmdb/mod.rs @@ -40,6 +40,44 @@ pub struct SimplifiedMovie { pub title: String // The title of the movie. } +#[derive(Deserialize)] +#[rustfmt::skip] +pub struct Show { + pub backdrop_path: Option, // The show's backdrop path. + pub created_by: Vec, // The show's creators. + pub episode_run_time: Vec, // An array containing the show's episode runtimes. + pub first_air_date: NaiveDate, // The date the show first aired. + pub genres: Vec, // The genres that the show is in. + pub homepage: String, // The show's homepage. + pub id: i64, // The show's id on The Movie Database. + pub in_production: bool, // Whether or not the show is currently in production. + pub languages: Vec, // The show's available languages. + pub last_air_date: NaiveDate, // When the show last aired an episode. + pub last_episode_to_air: EpisodeToAir, // The show's last aired episode. + pub name: String, // The name of the show. + pub next_episode_to_air: Option, // The show's next scheduled episode. + pub networks: Vec, // The networks or services that air the show. + pub number_of_episodes: i64, // The total number of episodes the show has aired. + pub number_of_seasons: i64, // The total number of seasons the show has released. + pub origin_country: Vec, // The country where the show originated. + pub original_language: String, // The original language of the show. + pub original_name: String, // The show's original name. + pub overview: String, // The show's overview. + pub popularity: f64, // An integer containing the show's popularity value. + pub poster_path: Option, // The show's poster path. + #[serde(rename = "production_companies")] + pub studios: Vec, // The studios that produce and manage the show. + pub seasons: Vec, // A vector array containing information on the show's individual seasons. + pub spoken_languages: Vec, // A vector array containing information about the show's spoken languages. + pub status: String, // The status of the show; can be Returning Series, Cancelled, or Ended. + pub tagline: String, // The show's tagline. + #[serde(rename = "type")] + pub format: String, // The format of the show; can be Scripted, News, or Unscripted. + pub vote_average: f64, // The show's average user score on The Movie Database. + pub vote_count: i64, // The show's total amount of user votes on The Movie Database. + // pub external_ids: ExternalId // The external IDs associated with the show, e.g. the external IMDb ID. +} + #[derive(Deserialize)] #[rustfmt::skip] pub struct Collection { @@ -49,66 +87,6 @@ pub struct Collection { pub backdrop_path: String // the backdrop of the collection. } -#[derive(Deserialize)] -#[rustfmt::skip] -pub struct Genre { - pub id: u64, // The genre's ID. - pub name: String // The genre's name. -} - -#[derive(Deserialize)] -#[rustfmt::skip] -pub struct ProductionCompany { - pub name: String, // The friendly name of the production company. - pub id: u64, // The ID of the production company on The Movie Database. - pub origin_country: String // The country of origin of the production company. -} - -#[derive(Deserialize)] -#[rustfmt::skip] -pub struct ProductionCountry { - pub iso_3166_1: String, // The ISO standard shortcode of the production country. - pub name: String // The friendly name of the production country. -} - -#[derive(Deserialize)] -#[rustfmt::skip] -pub struct Show { - pub backdrop_path: Option, // The show's backdrop path. - pub created_by: Vec, // The show's creators. - pub episode_run_time: Vec, // An array containing the show's episode runtimes. - pub first_air_date: NaiveDate, // The date the show first aired. - pub genres: Vec, // The genres that the show is in. - pub homepage: String, // The show's homepage. - pub id: i64, // The show's id on The Movie Database. - pub in_production: bool, // Whether or not the show is currently in production. - pub languages: Vec, // The show's available languages. - pub last_air_date: NaiveDate, // When the show last aired an episode. - pub last_episode_to_air: EpisodeToAir, // The show's last aired episode. - pub name: String, // The name of the show. - pub next_episode_to_air: Option, // The show's next scheduled episode. - pub networks: Vec, // The networks or services that air the show. - pub number_of_episodes: i64, // The total number of episodes the show has aired. - pub number_of_seasons: i64, // The total number of seasons the show has released. - pub origin_country: Vec, // The country where the show originated. - pub original_language: String, // The original language of the show. - pub original_name: String, // The show's original name. - pub overview: String, // The show's overview. - pub popularity: f64, // An integer containing the show's popularity value. - pub poster_path: Option, // The show's poster path. - #[serde(rename = "production_companies")] - pub studios: Vec, // The studios that produce and manage the show. - pub seasons: Vec, // A vector array containing information on the show's individual seasons. - pub spoken_languages: Vec, // A vector array containing information about the show's spoken languages. - pub status: String, // The status of the show; can be Returning Series, Cancelled, or Ended. - pub tagline: String, // The show's tagline. - #[serde(rename = "type")] - pub format: String, // The format of the show; can be Scripted, News, or Unscripted. - pub vote_average: f64, // The show's average user score on The Movie Database. - pub vote_count: i64, // The show's total amount of user votes on The Movie Database. - // pub external_ids: ExternalId // The external IDs associated with the show, e.g. the external IMDb ID. -} - #[derive(Deserialize)] #[rustfmt::skip] pub struct CreatedBy { @@ -119,6 +97,13 @@ pub struct CreatedBy { pub profile_path: Option // The (optional) profile path of the given creator. } +#[derive(Deserialize)] +#[rustfmt::skip] +pub struct Genre { + pub id: u64, // The genre's ID. + pub name: String // The genre's name. +} + #[derive(Deserialize)] #[rustfmt::skip] pub struct EpisodeToAir { @@ -155,6 +140,7 @@ pub struct Season { pub season_number: i64 // The season's numerical number. } + #[derive(Deserialize)] #[rustfmt::skip] pub struct Language { @@ -176,3 +162,18 @@ pub struct ExternalId { pub twitter_id: Option, // The ID of the show's Twitter profile. pub id: Option // The show's The Movie Database identifier. } + +#[derive(Deserialize)] +#[rustfmt::skip] +pub struct ProductionCompany { + pub name: String, // The friendly name of the production company. + pub id: u64, // The ID of the production company on The Movie Database. + pub origin_country: String // The country of origin of the production company. +} + +#[derive(Deserialize)] +#[rustfmt::skip] +pub struct ProductionCountry { + pub iso_3166_1: String, // The ISO standard shortcode of the production country. + pub name: String // The friendly name of the production country. +}