using System; using System.Collections.Generic; using System.Linq; using TMDbLib.Client; using TMDbLib.Objects.Companies; using TMDbLib.Objects.General; using TMDbLib.Objects.Search; using TMDbLib.Objects.TvShows; using TMDbLib.Utilities; namespace TMDbLib.Objects.Discover { public class DiscoverTv : DiscoverBase { public DiscoverTv(TMDbClient client) : base("discover/tv", client) { } /// /// Available options are vote_average.desc, vote_average.asc, first_air_date.desc, first_air_date.asc, popularity.desc, popularity.asc /// public DiscoverTv OrderBy(DiscoverTvShowSortBy sortBy) { Parameters["sort_by"] = sortBy.GetDescription(); return this; } /// /// Specify a timeone to calculate proper date offsets. A list of valid timezones can be found by using the timezones/list method. /// public DiscoverTv UseTimezone(string timezone) { Parameters["timezone"] = timezone; return this; } /// /// The minimum episode air date to include. Expected format is YYYY-MM-DD. Can be used in conjunction with a specified timezone. /// public DiscoverTv WhereAirDateIsAfter(DateTime date) { Parameters["air_date.gte"] = date.ToString("yyyy-MM-dd"); return this; } /// /// The maximum episode air date to include. Expected format is YYYY-MM-DD. Can be used in conjunction with a specified timezone. /// public DiscoverTv WhereAirDateIsBefore(DateTime date) { Parameters["air_date.lte"] = date.ToString("yyyy-MM-dd"); return this; } /// /// The minimum release to include. Expected format is YYYY-MM-DD. /// public DiscoverTv WhereFirstAirDateIsAfter(DateTime date) { Parameters["first_air_date.gte"] = date.ToString("yyyy-MM-dd"); return this; } /// /// The maximum release to include. Expected format is YYYY-MM-DD. /// public DiscoverTv WhereFirstAirDateIsBefore(DateTime date) { Parameters["first_air_date.lte"] = date.ToString("yyyy-MM-dd"); return this; } /// /// Filter the results release dates to matches that include this value. Expected value is a year. /// public DiscoverTv WhereFirstAirDateIsInYear(int year) { Parameters["first_air_date_year"] = year.ToString("0000"); return this; } /// /// Only include TV shows with the specified genres. Expected value is an integer (the id of a genre). Multiple values can be specified. Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR'. /// public DiscoverTv WhereGenresInclude(IEnumerable genres) { return WhereGenresInclude(genres.Select(s => s.Id)); } /// /// Only include TV shows with the specified genres. Expected value is an integer (the id of a genre). Multiple values can be specified. Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR'. /// public DiscoverTv WhereGenresInclude(IEnumerable genreIds) { Parameters["with_genres"] = string.Join(",", genreIds.Select(s => s.ToString())); return this; } /// /// Filter TV shows to include a specific network. Expected value is an integer (the id of a network). They can be comma separated to indicate an 'AND' query. /// public DiscoverTv WhereNetworksInclude(IEnumerable networks) { return WhereNetworksInclude(networks.Select(s => s.Id)); } /// /// Filter TV shows to include a specific network. Expected value is an integer (the id of a network). They can be comma separated to indicate an 'AND' query. /// public DiscoverTv WhereNetworksInclude(IEnumerable networkIds) { Parameters["with_networks"] = string.Join(",", networkIds.Select(s => s.ToString())); return this; } /// /// Only include TV shows that are equal to, or have a higher average rating than this value. Expected value is a float. /// public DiscoverTv WhereVoteAverageIsAtLeast(double score) { // TODO: Apply culture to the ToString Parameters["vote_average.gte"] = score.ToString(); return this; } /// /// Only include TV shows that are equal to, or have a vote count higher than this value. Expected value is an integer. /// public DiscoverTv WhereVoteCountIsAtLeast(int count) { Parameters["vote_count.gte"] = count.ToString(); return this; } /// /// Specifies which language to use for translatable fields /// public DiscoverTv WhereOriginalLanguageIs(string language) { Parameters["with_original_language"] = language; return this; } /// /// Only include TV shows that are equal to, or have a runtime higher than this value. Expected value is an integer (minutes). /// public DiscoverTv WhereRuntimeIsAtLeast(int minutes) { Parameters["with_runtime.gte"] = minutes.ToString(); return this; } /// /// Only include TV shows that are equal to, or have a runtime lower than this value. Expected value is an integer (minutes). /// public DiscoverTv WhereRuntimeIsAtMost(int minutes) { Parameters["with_runtime.lte"] = minutes.ToString(); return this; } /// /// Toggle the inclusion of TV shows with null first air data. Expected value is a boolean, true or false. /// public DiscoverTv IncludeNullFirstAirDates(bool include) { Parameters["include_null_first_air_dates"] = include.ToString(); return this; } /// /// Exclude TV shows with the specified genres. Expected value is a list of Generes. /// public DiscoverTv WhereGenresExclude(IEnumerable genres) { return WhereGenresInclude(genres.Select(s => s.Id)); } /// /// Exclude TV shows with the specified genres. Expected value is an integer (the id of a genre). /// public DiscoverTv WhereGenresExclude(IEnumerable genreIds) { Parameters["without_genres"] = string.Join(",", genreIds.Select(s => s.ToString())); return this; } /// /// Only include TV shows with the specified companies. Expected value is an list of companies. /// public DiscoverTv WhereCompaniesInclude(IEnumerable companies) { return WhereCompaniesInclude(companies.Select(s => s.Id)); } /// /// Only include TV shows with the specified companies. Expected value is a list of integer (the id of a company). /// public DiscoverTv WhereCompaniesInclude(IEnumerable companyIds) { Parameters["with_companies"] = string.Join(",", companyIds.Select(s => s.ToString())); return this; } /// /// Filter results to include items that have been screened theatrically. /// public DiscoverTv WhereScreenedTheatrically(bool theatrical) { Parameters["screened_theatrically"] = theatrical.ToString(); return this; } /// /// Filter TV shows to include a specific keyword. Expected value is a list of keywords. /// public DiscoverTv WhereKeywordsInclude(IEnumerable keywords) { return WhereKeywordsInclude(keywords.Select(s => s.Id)); } /// /// Filter TV shows to include a specific keyword. Expected value is a list of integer (the id of a keyword). /// public DiscoverTv WhereKeywordsInclude(IEnumerable keywordIds) { Parameters["with_keywords"] = string.Join(",", keywordIds.Select(s => s.ToString())); return this; } /// /// Filter TV shows to exclude a specific keyword. Expected value is a list of keywords. /// public DiscoverTv WhereKeywordsExclude(IEnumerable keywords) { return WhereKeywordsInclude(keywords.Select(s => s.Id)); } /// /// Filter TV shows to exclude a specific keyword. Expected value is a list of integer (the id of a keyword). /// public DiscoverTv WhereKeywordsExclude(IEnumerable keywordIds) { Parameters["without_keywords"] = string.Join("|", keywordIds.Select(s => s.ToString())); return this; } /// /// Specifies which language to use for translatable fields /// public DiscoverTv WhereLanguageIs(string language) { Parameters["language"] = language; return this; } } }