using System; using System.Collections.Generic; using System.Linq; using TMDbLib.Objects.Companies; using TMDbLib.Objects.General; using TMDbLib.Client; using TMDbLib.Objects.Search; using TMDbLib.Objects.TvShows; using TMDbLib.Utilities; namespace TMDbLib.Objects.Discover { public class DiscoverMovie : DiscoverBase { public DiscoverMovie(TMDbClient client) : base("discover/movie", client) { } private void ClearCertification() { Parameters.Remove("certification_country"); Parameters.Remove("certification"); Parameters.Remove("certification.lte"); Parameters.Remove("certification.gte"); } /// /// Toggle the inclusion of adult titles. Expected value is a boolean, true or false. Default is false. /// public DiscoverMovie IncludeAdultMovies(bool include = true) { Parameters["include_adult"] = include.ToString(); return this; } /// /// Toggle the inclusion of items marked as a video. Expected value is a boolean, true or false. Default is true. /// public DiscoverMovie IncludeVideoMovies(bool include = true) { Parameters["include_video"] = include.ToString(); return this; } /// /// Only include movies that have this person id added as a cast member. Expected value is an integer (the id of a person). /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfCast(IEnumerable castIds) { Parameters["with_cast"] = string.Join(",", castIds.Select(s => s.ToString())); return this; } /// /// Only include movies that have this person id added as a cast member. /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfCast(IEnumerable casts) { return IncludeWithAllOfCast(casts.Select(s => s.Id)); } /// /// Only include movies that have this company id added as a crew member. Expected value is an integer (the id of a company). /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfCompany(IEnumerable companyIds) { Parameters["with_companies"] = string.Join(",", companyIds.Select(s => s.ToString())); return this; } /// /// Only include movies that have this company id added as a crew member. /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfCompany(IEnumerable companies) { return IncludeWithAllOfCompany(companies.Select(s => s.Id)); } /// /// Only include movies that have this person id added as a crew member. Expected value is an integer (the id of a person). /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfCrew(IEnumerable crewIds) { Parameters["with_crew"] = string.Join(",", crewIds.Select(s => s.ToString())); return this; } /// /// Only include movies that have this person id added as a crew member. /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfCrew(IEnumerable crews) { return IncludeWithAllOfCrew(crews.Select(s => s.Id)); } /// /// Only include movies with the specified genres. Expected value is an integer (the id of a genre). /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfGenre(IEnumerable genreIds) { Parameters["with_genres"] = string.Join(",", genreIds.Select(s => s.ToString())); return this; } /// /// Only include movies with the specified genres. /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfGenre(IEnumerable genres) { return IncludeWithAllOfGenre(genres.Select(s => s.Id)); } /// /// Only include movies with the specified keywords. Expected value is an integer (the id of a keyword). /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfKeywords(IEnumerable keywordIds) { Parameters["with_keywords"] = string.Join(",", keywordIds.Select(s => s.ToString())); return this; } /// /// Only include movies with the specified keywords. /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfKeywords(IEnumerable keywords) { return IncludeWithAllOfKeywords(keywords.Select(s => s.Id)); } /// /// Only include movies that have these person id's added as a cast or crew member. Expected value is an integer (the id or ids of a person). /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfPeople(IEnumerable peopleIds) { Parameters["with_people"] = string.Join(",", peopleIds.Select(s => s.ToString())); return this; } /// /// Only include movies that have these person id's added as a cast or crew member. /// This method performs an AND query. /// public DiscoverMovie IncludeWithAllOfPeople(IEnumerable people) { return IncludeWithAllOfPeople(people.Select(s => s.Id)); } /// /// Only include movies that have this person id added as a cast member. Expected value is an integer (the id of a person). /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfCast(IEnumerable castIds) { Parameters["with_cast"] = string.Join("|", castIds.Select(s => s.ToString())); return this; } /// /// Only include movies that have this person id added as a cast member. /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfCast(IEnumerable casts) { return IncludeWithAnyOfCast(casts.Select(s => s.Id)); } /// /// Only include movies that have this company id added as a crew member. Expected value is an integer (the id of a company). /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfCompany(IEnumerable companyIds) { Parameters["with_companies"] = string.Join("|", companyIds.Select(s => s.ToString())); return this; } /// /// Only include movies that have this company id added as a crew member. /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfCompany(IEnumerable companies) { return IncludeWithAnyOfCompany(companies.Select(s => s.Id)); } /// /// Only include movies that have this person id added as a crew member. Expected value is an integer (the id of a person). /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfCrew(IEnumerable crewIds) { Parameters["with_crew"] = string.Join("|", crewIds.Select(s => s.ToString())); return this; } /// /// Only include movies that have this person id added as a crew member. /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfCrew(IEnumerable crews) { return IncludeWithAnyOfCrew(crews.Select(s => s.Id)); } /// /// Only include movies with the specified genres. Expected value is an integer (the id of a genre). /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfGenre(IEnumerable castIds) { Parameters["with_genres"] = string.Join("|", castIds.Select(s => s.ToString())); return this; } /// /// Only include movies with the specified genres. /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfGenre(IEnumerable genres) { return IncludeWithAnyOfGenre(genres.Select(s => s.Id)); } /// /// Only include movies with the specified keywords. Expected value is an integer (the id of a keyword). /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfKeywords(IEnumerable keywordIds) { Parameters["with_keywords"] = string.Join("|", keywordIds.Select(s => s.ToString())); return this; } /// /// Only include movies with the specified keywords. /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfKeywords(IEnumerable keywords) { return IncludeWithAnyOfKeywords(keywords.Select(s => s.Id)); } /// /// Only include movies that have these person id's added as a cast or crew member. Expected value is an integer (the id or ids of a person). /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfPeople(IEnumerable peopleIds) { Parameters["with_people"] = string.Join("|", peopleIds.Select(s => s.ToString())); return this; } /// /// Only include movies that have these person id's added as a cast or crew member. /// This method performs an OR query. /// public DiscoverMovie IncludeWithAnyOfPeople(IEnumerable people) { return IncludeWithAnyOfPeople(people.Select(s => s.Id)); } /// /// Available options are: popularity.ascpopularity.descrelease_date.ascrelease_date.descrevenue.ascrevenue.descprimary_release_date.ascprimary_release_date.descoriginal_title.ascoriginal_title.descvote_average.ascvote_average.descvote_count.ascvote_count.desc /// public DiscoverMovie OrderBy(DiscoverMovieSortBy sortBy) { Parameters["sort_by"] = sortBy.GetDescription(); return this; } /// /// Filter the results by all available release dates that have the specified value added as a year. Expected value is an integer (year). /// public DiscoverMovie WhereAnyReleaseDateIsInYear(int year) { Parameters["year"] = year.ToString("0000"); return this; } /// /// Only include movies with this certification. Expected value is a valid certification for the specificed 'certification_country'. /// public DiscoverMovie WhereCertificationIs(string country, string certification) { ClearCertification(); Parameters["certification_country"] = country; Parameters["certification"] = certification; return this; } /// /// Only include movies with this certification and lower. Expected value is a valid certification for the specificed 'certification_country'. /// public DiscoverMovie WhereCertificationIsAtMost(string country, string maxCertification) { ClearCertification(); Parameters["certification_country"] = country; Parameters["certification.lte"] = maxCertification; return this; } /// /// Only include movies with this certification and higher. Expected value is a valid certification for the specificed 'certification_country'. /// public DiscoverMovie WhereCertificationIsAtLeast(string country, string minCertification) { ClearCertification(); Parameters["certification_country"] = country; Parameters["certification.gte"] = minCertification; return this; } /// /// Filter by the primary release date and only include those which are greater than or equal to the specified value. Expected format is YYYY-MM-DD. /// public DiscoverMovie WherePrimaryReleaseDateIsAfter(DateTime date) { Parameters["primary_release_date.gte"] = date.ToString("yyyy-MM-dd"); return this; } /// /// Filter by the primary release date and only include those which are greater than or equal to the specified value. Expected format is YYYY-MM-DD. /// public DiscoverMovie WherePrimaryReleaseDateIsBefore(DateTime date) { Parameters["primary_release_date.lte"] = date.ToString("yyyy-MM-dd"); return this; } /// /// Filter the results so that only the primary release date year has this value. Expected value is a year. /// public DiscoverMovie WherePrimaryReleaseIsInYear(int year) { Parameters["primary_release_year"] = year.ToString("0000"); return this; } /// /// Filter by all available release dates and only include those which are greater or equal to the specified value. Expected format is YYYY-MM-DD. /// public DiscoverMovie WhereReleaseDateIsAfter(DateTime date) { Parameters["release_date.gte"] = date.ToString("yyyy-MM-dd"); return this; } /// /// Filter by all available release dates and only include those which are less or equal to the specified value. Expected format is YYYY-MM-DD. /// public DiscoverMovie WhereReleaseDateIsBefore(DateTime date) { Parameters["release_date.lte"] = date.ToString("yyyy-MM-dd"); return this; } /// /// Filter movies by their vote average and only include those that have an average rating that is equal to or higher than the specified value. Expected value is a float. /// public DiscoverMovie WhereVoteAverageIsAtLeast(double score) { // TODO: Apply culture to the ToString Parameters["vote_average.gte"] = score.ToString(); return this; } /// /// Filter movies by their vote average and only include those that have an average rating that is equal to or lower than the specified value. Expected value is a float. /// public DiscoverMovie WhereVoteAverageIsAtMost(double score) { // TODO: Apply culture to the ToString Parameters["vote_average.lte"] = score.ToString(); return this; } /// /// Filter movies by their vote count and only include movies that have a vote count that is equal to or lower than the specified value. /// public DiscoverMovie WhereVoteCountIsAtLeast(int count) { Parameters["vote_count.gte"] = count.ToString(); return this; } /// /// Filter movies by their vote count and only include movies that have a vote count that is equal to or lower than the specified value. Expected value is an integer. /// public DiscoverMovie WhereVoteCountIsAtMost(int count) { Parameters["vote_count.lte"] = count.ToString(); return this; } /// /// Specifies which region to use for release date filtering (using ISO 3166-1 code) /// public DiscoverMovie WhereReleaseDateIsInRegion(string region) { Parameters["region"] = region; return this; } /// /// Specifies which language to use for translatable fields /// public DiscoverMovie WhereLanguageIs(string language) { Parameters["language"] = language; return this; } /// /// Specifies which language to use for translatable fields /// public DiscoverMovie WhereOriginalLanguageIs(string language) { Parameters["with_original_language"] = language; return this; } } }