From 22d47512b692a4cac9d54f752ec445ee7bacd3cd Mon Sep 17 00:00:00 2001 From: Taylor Buchanan Date: Tue, 22 Oct 2019 12:12:20 -0500 Subject: [PATCH] Add comments to clarify filter decisions --- src/Ombi.TheMovieDbApi/TheMovieDbApi.cs | 32 ++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs index 7c24d4c60..b5f0a1596 100644 --- a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs @@ -133,11 +133,15 @@ namespace Ombi.Api.TheMovieDb return Mapper.Map>(result.results); } + /// + /// Maintains filter parity with /movie/popular. + /// public async Task> PopularMovies(string langCode) { var request = new Request($"discover/movie", BaseUri, HttpMethod.Get); request.AddQueryString("api_key", ApiToken); request.AddQueryString("language", langCode); + request.AddQueryString("sort_by", "popularity.desc"); var settings = await Settings; request.AddQueryString("include_adult", settings.ShowAdultMovies.ToString().ToLower()); request.AddQueryString("without_keywords", settings.ExcludedKeywordIds); @@ -147,13 +151,21 @@ namespace Ombi.Api.TheMovieDb return Mapper.Map>(result.results); } + /// + /// Maintains filter parity with /movie/top_rated. + /// public async Task> TopRated(string langCode) { var request = new Request($"discover/movie", BaseUri, HttpMethod.Get); request.AddQueryString("api_key", ApiToken); request.AddQueryString("language", langCode); - request.AddQueryString("vote_count.gte", "250"); request.AddQueryString("sort_by", "vote_average.desc"); + + // `vote_count` consideration isn't explicitly documented, but using only the `sort_by` filter + // does not provide the same results as `/movie/top_rated`. This appears to be adequate enough + // to filter out extremely high-rated movies due to very little votes + request.AddQueryString("vote_count.gte", "250"); + var settings = await Settings; request.AddQueryString("include_adult", settings.ShowAdultMovies.ToString().ToLower()); request.AddQueryString("without_keywords", settings.ExcludedKeywordIds); @@ -163,15 +175,24 @@ namespace Ombi.Api.TheMovieDb return Mapper.Map>(result.results); } + /// + /// Maintains filter parity with /movie/upcoming. + /// public async Task> Upcoming(string langCode) { var request = new Request($"discover/movie", BaseUri, HttpMethod.Get); request.AddQueryString("api_key", ApiToken); request.AddQueryString("language", langCode); + + // Release types "2 or 3" explicitly stated as used in docs request.AddQueryString("with_release_type", "2|3"); + + // The date range being used in `/movie/upcoming` isn't documented, but we infer it is + // an offset from today based on the minimum and maximum date they provide in the output var startDate = DateTime.Today.AddDays(7); request.AddQueryString("release_date.gte", startDate.ToString("yyyy-MM-dd")); request.AddQueryString("release_date.lte", startDate.AddDays(17).ToString("yyyy-MM-dd")); + var settings = await Settings; request.AddQueryString("include_adult", settings.ShowAdultMovies.ToString().ToLower()); request.AddQueryString("without_keywords", settings.ExcludedKeywordIds); @@ -181,15 +202,24 @@ namespace Ombi.Api.TheMovieDb return Mapper.Map>(result.results); } + /// + /// Maintains filter parity with /movie/now_playing. + /// public async Task> NowPlaying(string langCode) { var request = new Request($"discover/movie", BaseUri, HttpMethod.Get); request.AddQueryString("api_key", ApiToken); request.AddQueryString("language", langCode); + + // Release types "2 or 3" explicitly stated as used in docs request.AddQueryString("with_release_type", "2|3"); + + // The date range being used in `/movie/now_playing` isn't documented, but we infer it is + // an offset from today based on the minimum and maximum date they provide in the output var today = DateTime.Today; request.AddQueryString("release_date.gte", today.AddDays(-42).ToString("yyyy-MM-dd")); request.AddQueryString("release_date.lte", today.AddDays(6).ToString("yyyy-MM-dd")); + var settings = await Settings; request.AddQueryString("include_adult", settings.ShowAdultMovies.ToString().ToLower()); request.AddQueryString("without_keywords", settings.ExcludedKeywordIds);