Пример #1
0
        public IDictionary <string, object> ToArguments()
        {
            var result = new JsonObject();

            if (TmdbDiscoverShowsSortType.Default != SortBy)
            {
                var sfx  = (byte)SortBy > 0x7F ? ".asc" : ".desc";
                var sort = (TmdbDiscoverShowsSortType)(((byte)SortBy) & 0x7F);
                switch (sort)
                {
                case TmdbDiscoverShowsSortType.Popularity:
                    result.Add("sort_by", "popularity" + sfx);
                    break;

                case TmdbDiscoverShowsSortType.VoteAverage:
                    result.Add("sort_by", "vote_average" + sfx);
                    break;

                case TmdbDiscoverShowsSortType.VoteCount:
                    result.Add("sort_by", "vote_count" + sfx);
                    break;

                case TmdbDiscoverShowsSortType.FirstAirDate:
                    result.Add("sort_by", "first_air_date" + sfx);
                    break;
                }
            }

            if (default(DateTime) != AirDateMaximum)
            {
                result.Add("air_date.lte", AirDateMaximum.ToString("yyyy-MM-dd"));
            }

            if (default(DateTime) != AirDateMinimum)
            {
                result.Add("air_date.gte", AirDateMinimum.ToString("yyyy-MM-dd"));
            }

            if (default(DateTime) != FirstAirDateMaximum)
            {
                result.Add("first_air_date.lte", FirstAirDateMaximum.ToString("yyyy-MM-dd"));
            }

            if (default(DateTime) != FirstAirDateMinimum)
            {
                result.Add("first_air_date.gte", FirstAirDateMinimum.ToString("yyyy-MM-dd"));
            }

            if (!string.IsNullOrEmpty(TimeZone))
            {
                result.Add("timezone", TimeZone);
            }

            if (0 != FirstAirDateYear)
            {
                result.Add("first_air_date_year=", FirstAirDateYear);
            }

            if (0d < VoteAverageMinimum)
            {
                result.Add("vote_average.gte", VoteAverageMinimum);
            }

            var sb = new StringBuilder();

            if (null != CompaniesAllOf || null != CompaniesAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, CompaniesAllOf, CompaniesAllOfIds, true);
                result.Add("with_companies", sb.ToString());
            }
            else if (null != CompaniesAnyOf || null != CompaniesAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, CompaniesAnyOf, CompaniesAnyOfIds, false);
                result.Add("with_companies", sb.ToString());
            }

            if (null != NetworksAllOf || null != NetworksAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, NetworksAllOf, NetworksAllOfIds, true);
                result.Add("with_networks", sb.ToString());
            }
            else if (null != NetworksAnyOf || null != NetworksAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, NetworksAnyOf, NetworksAnyOfIds, false);
                result.Add("with_networks", sb.ToString());
            }

            if (null != GenresAllOf || null != GenresAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, GenresAllOf, GenresAllOfIds, true);
                result.Add("with_genres", sb.ToString());
            }
            else if (null != GenresAnyOf || null != GenresAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, GenresAnyOf, GenresAnyOfIds, false);
                result.Add("with_genres", sb.ToString());
            }

            if (null != WithoutGenresAllOf || null != WithoutGenresAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, WithoutGenresAllOf, WithoutGenresAllOfIds, true);
                result.Add("without_genres", sb.ToString());
            }
            else if (null != WithoutGenresAnyOf || null != WithoutGenresAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, WithoutGenresAnyOf, WithoutGenresAnyOfIds, false);
                result.Add("without_genres", sb.ToString());
            }

            if (null != WithoutGenresAllOf || null != WithoutGenresAllOfIds)
            {
                sb.Append("&without_genres=");
                TmdbDiscoverUtility.AppendWith(sb, WithoutGenresAllOf, WithoutGenresAllOfIds, true);
            }
            else if (null != WithoutGenresAnyOf || null != WithoutGenresAnyOfIds)
            {
                sb.Append("&without_genres=");
                TmdbDiscoverUtility.AppendWith(sb, WithoutGenresAnyOf, WithoutGenresAnyOfIds, true);
            }
            if (null != KeywordsAllOf || null != KeywordsAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, KeywordsAllOf, KeywordsAllOfIds, true);
                result.Add("with_keywords", sb.ToString());
            }
            else if (null != KeywordsAnyOf || null != KeywordsAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, KeywordsAnyOf, KeywordsAnyOfIds, false);
                result.Add("with_keywords", sb.ToString());
            }

            if (null != WithoutKeywordsAllOf || null != WithoutKeywordsAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, WithoutKeywordsAllOf, WithoutKeywordsAllOfIds, true);
                result.Add("without_keywords", sb.ToString());
            }
            else if (null != WithoutKeywordsAnyOf || null != WithoutKeywordsAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, WithoutKeywordsAnyOf, WithoutKeywordsAnyOfIds, false);
                result.Add("without_keywords", sb.ToString());
            }

            if (default(TimeSpan) != RunTimeMaximum)
            {
                result.Add("runtime.lte", RunTimeMaximum.TotalMinutes);
            }

            if (default(TimeSpan) != RunTimeMinimum)
            {
                result.Add("runtime.gte", RunTimeMinimum.TotalMinutes);
            }

            if (!string.IsNullOrEmpty(OriginalLanguage))
            {
                result.Add("original_language", OriginalLanguage);
            }

            return(result);
        }
        public IDictionary <string, object> ToArguments()
        {
            var result = new JsonObject();

            if (TmdbDiscoverMoviesSortType.Default != SortBy)
            {
                var sfx  = (byte)SortBy > 0x7F ? ".asc" : ".desc";
                var sort = (TmdbDiscoverMoviesSortType)(((byte)SortBy) & 0x7F);
                switch (sort)
                {
                case TmdbDiscoverMoviesSortType.Popularity:
                    result.Add("sort_by", "popularity" + sfx);
                    break;

                case TmdbDiscoverMoviesSortType.VoteAverage:
                    result.Add("sort_by", "vote_average" + sfx);
                    break;

                case TmdbDiscoverMoviesSortType.VoteCount:
                    result.Add("sort_by", "vote_count" + sfx);
                    break;

                case TmdbDiscoverMoviesSortType.OriginalTitle:
                    result.Add("sort_by", "original_title" + sfx);
                    break;

                case TmdbDiscoverMoviesSortType.PrimaryReleaseDate:
                    result.Add("sort_by", "primary_release_date" + sfx);
                    break;

                case TmdbDiscoverMoviesSortType.ReleaseDate:
                    result.Add("sort_by", "release_date" + sfx);
                    break;

                case TmdbDiscoverMoviesSortType.Revenue:
                    result.Add("sort_by", "revenue" + sfx);
                    break;
                }
            }

            if (0d < VoteAverageMinimum)
            {
                result.Add("vote_average.gte", VoteAverageMinimum);
            }
            if (0d < VoteAverageMaximum)
            {
                result.Add("vote_average.lte", VoteAverageMaximum);
            }
            if (0d < VoteCountMinimum)
            {
                result.Add("vote_count.gte", VoteCountMinimum);
            }
            if (0d < VoteCountMaximum)
            {
                result.Add("vote_count.lte", VoteCountMaximum);
            }

            if (!string.IsNullOrEmpty(CertifiedRatingCountry))
            {
                result.Add("certification_country", CertifiedRatingCountry);
            }

            if (!string.IsNullOrEmpty(CertifiedRating))
            {
                result.Add("certification", CertifiedRating);
            }

            if (!string.IsNullOrEmpty(CertifiedRatingMaximum))
            {
                result.Add("certification.lte", CertifiedRatingMaximum);
            }

            if (!string.IsNullOrEmpty(CertifiedRatingMinimum))
            {
                result.Add("certification.gte", CertifiedRatingMinimum);
            }

            if (false != IncludeAdult)
            {
                result.Add("include_adult", true);
            }

            if (false != IncludeVideo)
            {
                result.Add("include_video", true);
            }

            if (0 < PrimaryReleaseYear)
            {
                result.Add("primary_release_year", PrimaryReleaseYear);
            }

            if (default(DateTime) != PrimaryReleaseDateMaximum)
            {
                result.Add("primary_release_date.lte", PrimaryReleaseDateMaximum.ToString("yyyy-MM-dd"));
            }

            if (default(DateTime) != PrimaryReleaseDateMinimum)
            {
                result.Add("primary_release_date.gte", PrimaryReleaseDateMinimum.ToString("yyyy-MM-dd"));
            }

            if (default(DateTime) != ReleaseDateMaximum)
            {
                result.Add("release_date.lte", ReleaseDateMaximum.ToString("yyyy-MM-dd"));
            }

            if (default(DateTime) != ReleaseDateMinimum)
            {
                result.Add("release_date.gte", ReleaseDateMinimum.ToString("yyyy-MM-dd"));
            }

            if (-1 != ReleaseType)
            {
                result.Add("with_release_type", ReleaseType);
            }

            if (0 != Year)
            {
                result.Add("year", Year);
            }
            var sb = new StringBuilder();

            if (null != CastAllOf || null != CastAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, CastAllOf, CastAllOfIds, true);
                result.Add("with_cast", sb.ToString());
            }
            else if (null != CastAnyOf || null != CastAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, CastAnyOf, CastAnyOfIds, false);
                result.Add("with_cast", sb.ToString());
            }
            if (null != CrewAllOf || null != CrewAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, CrewAllOf, CrewAllOfIds, true);
                result.Add("with_crew", sb.ToString());
            }
            else if (null != CrewAnyOf || null != CrewAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, CrewAnyOf, CrewAnyOfIds, false);
                result.Add("with_crew", sb.ToString());
            }
            if (null != PeopleAllOf || null != PeopleAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, PeopleAllOf, PeopleAllOfIds, true);
                result.Add("with_people", sb.ToString());
            }
            else if (null != PeopleAnyOf || null != PeopleAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, PeopleAnyOf, PeopleAnyOfIds, false);
                result.Add("with_people", sb.ToString());
            }
            if (null != CompaniesAllOf || null != CompaniesAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, CompaniesAllOf, CompaniesAllOfIds, true);
                result.Add("with_companies", sb.ToString());
            }
            else if (null != CompaniesAnyOf || null != CompaniesAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, CompaniesAnyOf, CompaniesAnyOfIds, false);
                result.Add("with_companies", sb.ToString());
            }

            if (null != GenresAllOf || null != GenresAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, GenresAllOf, GenresAllOfIds, true);
                result.Add("with_genres", sb.ToString());
            }
            else if (null != GenresAnyOf || null != GenresAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, GenresAnyOf, GenresAnyOfIds, false);
                result.Add("with_genres", sb.ToString());
            }

            if (null != WithoutGenresAllOf || null != WithoutGenresAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, WithoutGenresAllOf, WithoutGenresAllOfIds, true);
                result.Add("without_genres", sb.ToString());
            }
            else if (null != WithoutGenresAnyOf || null != WithoutGenresAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, WithoutGenresAnyOf, WithoutGenresAnyOfIds, false);
                result.Add("without_genres", sb.ToString());
            }

            if (null != WithoutGenresAllOf || null != WithoutGenresAllOfIds)
            {
                sb.Append("&without_genres=");
                TmdbDiscoverUtility.AppendWith(sb, WithoutGenresAllOf, WithoutGenresAllOfIds, true);
            }
            else if (null != WithoutGenresAnyOf || null != WithoutGenresAnyOfIds)
            {
                sb.Append("&without_genres=");
                TmdbDiscoverUtility.AppendWith(sb, WithoutGenresAnyOf, WithoutGenresAnyOfIds, true);
            }
            if (null != KeywordsAllOf || null != KeywordsAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, KeywordsAllOf, KeywordsAllOfIds, true);
                result.Add("with_keywords", sb.ToString());
            }
            else if (null != KeywordsAnyOf || null != KeywordsAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, KeywordsAnyOf, KeywordsAnyOfIds, false);
                result.Add("with_keywords", sb.ToString());
            }

            if (null != WithoutKeywordsAllOf || null != WithoutKeywordsAllOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, WithoutKeywordsAllOf, WithoutKeywordsAllOfIds, true);
                result.Add("without_keywords", sb.ToString());
            }
            else if (null != WithoutKeywordsAnyOf || null != WithoutKeywordsAnyOfIds)
            {
                sb.Clear();
                TmdbDiscoverUtility.AppendWith(sb, WithoutKeywordsAnyOf, WithoutKeywordsAnyOfIds, false);
                result.Add("without_keywords", sb.ToString());
            }

            if (default(TimeSpan) != RunTimeMaximum)
            {
                result.Add("runtime.lte", RunTimeMaximum.TotalMinutes);
            }

            if (default(TimeSpan) != RunTimeMinimum)
            {
                result.Add("runtime.gte", RunTimeMinimum.TotalMinutes);
            }

            if (!string.IsNullOrEmpty(OriginalLanguage))
            {
                result.Add("original_language", OriginalLanguage);
            }

            return(result);
        }