use super::{date::PartialDate, genre::Genre, media_id::MediaId, models::*};
impl UnifiedMovie {
pub fn new(provider_id: MediaId, title: impl Into<String>) -> Self {
Self {
provider_id,
title: title.into(),
original_title: None,
overview: None,
release_date: None,
poster_url: None,
backdrop_url: None,
genres: Vec::new(),
popularity: None,
vote_average: None,
vote_count: None,
original_language: None,
adult: None,
}
}
pub fn with_original_title(mut self, value: impl Into<String>) -> Self {
self.original_title = Some(value.into());
self
}
pub fn with_overview(mut self, value: impl Into<String>) -> Self {
self.overview = Some(value.into());
self
}
pub fn with_release_date(mut self, value: PartialDate) -> Self {
self.release_date = Some(value);
self
}
pub fn with_poster_url(mut self, value: impl Into<String>) -> Self {
self.poster_url = Some(value.into());
self
}
pub fn with_backdrop_url(mut self, value: impl Into<String>) -> Self {
self.backdrop_url = Some(value.into());
self
}
pub fn with_genres(mut self, value: Vec<Genre>) -> Self {
self.genres = value;
self
}
pub fn with_popularity(mut self, value: f64) -> Self {
self.popularity = Some(value);
self
}
pub fn with_vote_average(mut self, value: f64) -> Self {
self.vote_average = Some(value);
self
}
pub fn with_vote_count(mut self, value: u64) -> Self {
self.vote_count = Some(value);
self
}
pub fn with_original_language(mut self, value: impl Into<String>) -> Self {
self.original_language = Some(value.into());
self
}
pub fn with_adult(mut self, value: bool) -> Self {
self.adult = Some(value);
self
}
}
impl UnifiedMovieDetails {
pub fn new(movie: UnifiedMovie) -> Self {
Self {
movie,
tagline: None,
runtime: None,
budget: None,
revenue: None,
status: None,
homepage: None,
imdb_id: None,
production_companies: Vec::new(),
production_countries: Vec::new(),
spoken_languages: Vec::new(),
video: false,
belongs_to_collection: None,
}
}
pub fn with_tagline(mut self, value: impl Into<String>) -> Self {
self.tagline = Some(value.into());
self
}
pub fn with_runtime(mut self, value: u32) -> Self {
self.runtime = Some(value);
self
}
pub fn with_budget(mut self, value: u64) -> Self {
self.budget = Some(value);
self
}
pub fn with_revenue(mut self, value: u64) -> Self {
self.revenue = Some(value);
self
}
pub fn with_status(mut self, value: impl Into<String>) -> Self {
self.status = Some(value.into());
self
}
pub fn with_homepage(mut self, value: impl Into<String>) -> Self {
self.homepage = Some(value.into());
self
}
pub fn with_imdb_id(mut self, value: impl Into<String>) -> Self {
self.imdb_id = Some(value.into());
self
}
pub fn with_production_companies(mut self, value: Vec<Company>) -> Self {
self.production_companies = value;
self
}
pub fn with_production_countries(mut self, value: Vec<String>) -> Self {
self.production_countries = value;
self
}
pub fn with_spoken_languages(mut self, value: Vec<String>) -> Self {
self.spoken_languages = value;
self
}
pub fn with_video(mut self, value: bool) -> Self {
self.video = value;
self
}
pub fn with_collection(mut self, value: Collection) -> Self {
self.belongs_to_collection = Some(value);
self
}
}
impl UnifiedTvShow {
pub fn new(provider_id: MediaId, name: impl Into<String>) -> Self {
Self {
provider_id,
name: name.into(),
original_name: None,
overview: None,
first_air_date: None,
poster_url: None,
backdrop_url: None,
genres: Vec::new(),
popularity: None,
vote_average: None,
vote_count: None,
original_language: None,
origin_country: Vec::new(),
adult: None,
}
}
pub fn with_original_name(mut self, value: impl Into<String>) -> Self {
self.original_name = Some(value.into());
self
}
pub fn with_overview(mut self, value: impl Into<String>) -> Self {
self.overview = Some(value.into());
self
}
pub fn with_first_air_date(mut self, value: PartialDate) -> Self {
self.first_air_date = Some(value);
self
}
pub fn with_poster_url(mut self, value: impl Into<String>) -> Self {
self.poster_url = Some(value.into());
self
}
pub fn with_backdrop_url(mut self, value: impl Into<String>) -> Self {
self.backdrop_url = Some(value.into());
self
}
pub fn with_genres(mut self, value: Vec<Genre>) -> Self {
self.genres = value;
self
}
pub fn with_popularity(mut self, value: f64) -> Self {
self.popularity = Some(value);
self
}
pub fn with_vote_average(mut self, value: f64) -> Self {
self.vote_average = Some(value);
self
}
pub fn with_vote_count(mut self, value: u64) -> Self {
self.vote_count = Some(value);
self
}
pub fn with_original_language(mut self, value: impl Into<String>) -> Self {
self.original_language = Some(value.into());
self
}
pub fn with_origin_country(mut self, value: Vec<String>) -> Self {
self.origin_country = value;
self
}
pub fn with_adult(mut self, value: bool) -> Self {
self.adult = Some(value);
self
}
}
impl UnifiedTvShowDetails {
pub fn new(show: UnifiedTvShow) -> Self {
Self {
show,
tagline: None,
number_of_seasons: None,
number_of_episodes: None,
in_production: false,
status: None,
homepage: None,
networks: Vec::new(),
production_companies: Vec::new(),
last_air_date: None,
type_: None,
media_format: None,
created_by: Vec::new(),
episode_run_time: Vec::new(),
spoken_languages: Vec::new(),
production_countries: Vec::new(),
seasons: Vec::new(),
}
}
pub fn with_tagline(mut self, value: impl Into<String>) -> Self {
self.tagline = Some(value.into());
self
}
pub fn with_number_of_seasons(mut self, value: u32) -> Self {
self.number_of_seasons = Some(value);
self
}
pub fn with_number_of_episodes(mut self, value: u32) -> Self {
self.number_of_episodes = Some(value);
self
}
pub fn with_in_production(mut self, value: bool) -> Self {
self.in_production = value;
self
}
pub fn with_status(mut self, value: impl Into<String>) -> Self {
self.status = Some(value.into());
self
}
pub fn with_homepage(mut self, value: impl Into<String>) -> Self {
self.homepage = Some(value.into());
self
}
pub fn with_networks(mut self, value: Vec<Network>) -> Self {
self.networks = value;
self
}
pub fn with_production_companies(mut self, value: Vec<Company>) -> Self {
self.production_companies = value;
self
}
pub fn with_last_air_date(mut self, value: PartialDate) -> Self {
self.last_air_date = Some(value);
self
}
pub fn with_type(mut self, value: impl Into<String>) -> Self {
self.type_ = Some(value.into());
self
}
pub fn with_media_format(mut self, value: impl Into<String>) -> Self {
self.media_format = Some(value.into());
self
}
pub fn with_created_by(mut self, value: Vec<Creator>) -> Self {
self.created_by = value;
self
}
pub fn with_episode_run_time(mut self, value: Vec<u32>) -> Self {
self.episode_run_time = value;
self
}
pub fn with_spoken_languages(mut self, value: Vec<String>) -> Self {
self.spoken_languages = value;
self
}
pub fn with_production_countries(mut self, value: Vec<String>) -> Self {
self.production_countries = value;
self
}
pub fn with_seasons(mut self, value: Vec<UnifiedSeason>) -> Self {
self.seasons = value;
self
}
}
impl UnifiedSeason {
pub fn new(season_number: u32) -> Self {
Self {
season_number,
name: None,
overview: None,
air_date: None,
episode_count: None,
poster_url: None,
}
}
pub fn with_name(mut self, value: impl Into<String>) -> Self {
self.name = Some(value.into());
self
}
pub fn with_overview(mut self, value: impl Into<String>) -> Self {
self.overview = Some(value.into());
self
}
pub fn with_air_date(mut self, value: PartialDate) -> Self {
self.air_date = Some(value);
self
}
pub fn with_episode_count(mut self, value: u32) -> Self {
self.episode_count = Some(value);
self
}
pub fn with_poster_url(mut self, value: impl Into<String>) -> Self {
self.poster_url = Some(value.into());
self
}
}
impl UnifiedPerson {
pub fn new(provider_id: MediaId, name: impl Into<String>) -> Self {
Self {
provider_id,
name: name.into(),
known_for_department: None,
profile_url: None,
popularity: None,
gender: None,
adult: None,
}
}
pub fn with_known_for_department(mut self, value: impl Into<String>) -> Self {
self.known_for_department = Some(value.into());
self
}
pub fn with_profile_url(mut self, value: impl Into<String>) -> Self {
self.profile_url = Some(value.into());
self
}
pub fn with_popularity(mut self, value: f64) -> Self {
self.popularity = Some(value);
self
}
pub fn with_gender(mut self, value: Gender) -> Self {
self.gender = Some(value);
self
}
pub fn with_adult(mut self, value: bool) -> Self {
self.adult = Some(value);
self
}
}
impl UnifiedPersonDetails {
pub fn new(person: UnifiedPerson) -> Self {
Self {
person,
biography: None,
birthday: None,
deathday: None,
place_of_birth: None,
imdb_id: None,
homepage: None,
also_known_as: Vec::new(),
}
}
pub fn with_biography(mut self, value: impl Into<String>) -> Self {
self.biography = Some(value.into());
self
}
pub fn with_birthday(mut self, value: PartialDate) -> Self {
self.birthday = Some(value);
self
}
pub fn with_deathday(mut self, value: PartialDate) -> Self {
self.deathday = Some(value);
self
}
pub fn with_place_of_birth(mut self, value: impl Into<String>) -> Self {
self.place_of_birth = Some(value.into());
self
}
pub fn with_imdb_id(mut self, value: impl Into<String>) -> Self {
self.imdb_id = Some(value.into());
self
}
pub fn with_homepage(mut self, value: impl Into<String>) -> Self {
self.homepage = Some(value.into());
self
}
pub fn with_also_known_as(mut self, value: Vec<String>) -> Self {
self.also_known_as = value;
self
}
}
impl UnifiedSeasonDetails {
pub fn new(show_id: MediaId, season_number: u32) -> Self {
Self {
show_id,
season_number,
name: None,
overview: None,
air_date: None,
poster_url: None,
episodes: Vec::new(),
}
}
pub fn with_name(mut self, value: impl Into<String>) -> Self {
self.name = Some(value.into());
self
}
pub fn with_overview(mut self, value: impl Into<String>) -> Self {
self.overview = Some(value.into());
self
}
pub fn with_air_date(mut self, value: PartialDate) -> Self {
self.air_date = Some(value);
self
}
pub fn with_poster_url(mut self, value: impl Into<String>) -> Self {
self.poster_url = Some(value.into());
self
}
pub fn with_episodes(mut self, value: Vec<UnifiedEpisode>) -> Self {
self.episodes = value;
self
}
}
impl UnifiedEpisode {
pub fn new(episode_number: u32) -> Self {
Self {
episode_number,
name: None,
overview: None,
air_date: None,
runtime: None,
still_url: None,
vote_average: None,
}
}
pub fn with_name(mut self, value: impl Into<String>) -> Self {
self.name = Some(value.into());
self
}
pub fn with_overview(mut self, value: impl Into<String>) -> Self {
self.overview = Some(value.into());
self
}
pub fn with_air_date(mut self, value: PartialDate) -> Self {
self.air_date = Some(value);
self
}
pub fn with_runtime(mut self, value: u32) -> Self {
self.runtime = Some(value);
self
}
pub fn with_still_url(mut self, value: impl Into<String>) -> Self {
self.still_url = Some(value.into());
self
}
pub fn with_vote_average(mut self, value: f64) -> Self {
self.vote_average = Some(value);
self
}
}
impl UnifiedWatchProviders {
pub fn new(provider_id: MediaId) -> Self {
Self {
provider_id,
results: std::collections::HashMap::new(),
}
}
pub fn with_country(
mut self,
country_code: impl Into<String>,
entry: UnifiedWatchProviderEntry,
) -> Self {
self.results.insert(country_code.into(), entry);
self
}
}
impl UnifiedWatchProviderEntry {
pub fn new() -> Self {
Self::default()
}
pub fn with_flatrate(mut self, value: Vec<UnifiedStreamingService>) -> Self {
self.flatrate = value;
self
}
pub fn with_rent(mut self, value: Vec<UnifiedStreamingService>) -> Self {
self.rent = value;
self
}
pub fn with_buy(mut self, value: Vec<UnifiedStreamingService>) -> Self {
self.buy = value;
self
}
}
impl UnifiedStreamingService {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
logo_url: None,
}
}
pub fn with_logo_url(mut self, value: impl Into<String>) -> Self {
self.logo_url = Some(value.into());
self
}
}
impl Collection {
pub fn new(name: impl Into<String>) -> Self {
Self {
id: None,
name: name.into(),
poster_url: None,
backdrop_url: None,
}
}
pub fn with_id(mut self, value: u64) -> Self {
self.id = Some(value);
self
}
pub fn with_poster_url(mut self, value: impl Into<String>) -> Self {
self.poster_url = Some(value.into());
self
}
pub fn with_backdrop_url(mut self, value: impl Into<String>) -> Self {
self.backdrop_url = Some(value.into());
self
}
}
impl Company {
pub fn new(name: impl Into<String>) -> Self {
Self {
id: None,
name: name.into(),
logo_url: None,
origin_country: None,
}
}
pub fn with_id(mut self, value: u64) -> Self {
self.id = Some(value);
self
}
pub fn with_logo_url(mut self, value: impl Into<String>) -> Self {
self.logo_url = Some(value.into());
self
}
pub fn with_origin_country(mut self, value: impl Into<String>) -> Self {
self.origin_country = Some(value.into());
self
}
}
impl Network {
pub fn new(name: impl Into<String>) -> Self {
Self {
id: None,
name: name.into(),
logo_url: None,
origin_country: None,
}
}
pub fn with_id(mut self, value: u64) -> Self {
self.id = Some(value);
self
}
pub fn with_logo_url(mut self, value: impl Into<String>) -> Self {
self.logo_url = Some(value.into());
self
}
pub fn with_origin_country(mut self, value: impl Into<String>) -> Self {
self.origin_country = Some(value.into());
self
}
}
impl Creator {
pub fn new(name: impl Into<String>) -> Self {
Self {
id: None,
name: name.into(),
profile_url: None,
}
}
pub fn with_id(mut self, value: u64) -> Self {
self.id = Some(value);
self
}
pub fn with_profile_url(mut self, value: impl Into<String>) -> Self {
self.profile_url = Some(value.into());
self
}
}
impl UnifiedSearchResult {
pub fn movie(movie: UnifiedMovie) -> Self {
UnifiedSearchResult::Movie(movie)
}
pub fn tv_show(show: UnifiedTvShow) -> Self {
UnifiedSearchResult::TvShow(show)
}
pub fn person(person: UnifiedPerson) -> Self {
UnifiedSearchResult::Person(person)
}
}