diff --git a/src/Ombi.Core/Engine/MovieSearchEngine.cs b/src/Ombi.Core/Engine/MovieSearchEngine.cs index 682a999eb..975e48d11 100644 --- a/src/Ombi.Core/Engine/MovieSearchEngine.cs +++ b/src/Ombi.Core/Engine/MovieSearchEngine.cs @@ -161,7 +161,7 @@ namespace Ombi.Core.Engine var result = await Cache.GetOrAddAsync(CacheKeys.UpcomingMovies, async () => { var langCode = await DefaultLanguageCode(null); - return await MovieApi.Upcoming(langCode); + return await MovieApi.UpcomingMovies(langCode); }, DateTimeOffset.Now.AddHours(12)); if (result != null) { diff --git a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs index 3423bc139..27edbacbb 100644 --- a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs @@ -287,7 +287,7 @@ namespace Ombi.Core.Engine.V2 var result = await Cache.GetOrAddAsync(CacheKeys.UpcomingMovies, async () => { var langCode = await DefaultLanguageCode(null); - return await MovieApi.Upcoming(langCode); + return await MovieApi.UpcomingMovies(langCode); }, DateTimeOffset.Now.AddHours(12)); if (result != null) { @@ -307,7 +307,7 @@ namespace Ombi.Core.Engine.V2 foreach (var pagesToLoad in pages) { var apiResult = await Cache.GetOrAddAsync(nameof(UpcomingMovies) + pagesToLoad.Page + langCode, - () => MovieApi.Upcoming(langCode, pagesToLoad.Page), DateTimeOffset.Now.AddHours(12)); + () => MovieApi.UpcomingMovies(langCode, pagesToLoad.Page), DateTimeOffset.Now.AddHours(12)); results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take)); } return await TransformMovieResultsToResponse(results); diff --git a/src/Ombi.TheMovieDbApi/IMovieDbApi.cs b/src/Ombi.TheMovieDbApi/IMovieDbApi.cs index 4f3885ef0..12f5255b4 100644 --- a/src/Ombi.TheMovieDbApi/IMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/IMovieDbApi.cs @@ -22,7 +22,7 @@ namespace Ombi.Api.TheMovieDb Task> GetMoviesViaKeywords(string keywordId, string langCode, CancellationToken cancellationToken, int? page = null); Task> SearchTv(string searchTerm, string year = default); Task> TopRated(string languageCode, int? page = null); - Task> Upcoming(string languageCode, int? page = null); + Task> UpcomingMovies(string languageCode, int? page = null); Task> TopRatedTv(string languageCode, int? page = null); Task> TrendingTv(string languageCode, int? page = null); Task> UpcomingTv(string languageCode, int? page = null); diff --git a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs index ba61ccfcf..5b0817388 100644 --- a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs @@ -308,22 +308,12 @@ namespace Ombi.Api.TheMovieDb var result = await Api.Request>(request); return Mapper.Map>(result.results); } - - public Task> Upcoming(string langCode, int? page = null) - { - return Upcoming("movie", langCode, page); - } - public Task> UpcomingTv(string langCode, int? page = null) - { - return Upcoming("tv", langCode, page); - } - /// /// Maintains filter parity with /movie/upcoming. /// - private async Task> Upcoming(string type, string langCode, int? page = null) + public async Task> UpcomingMovies(string langCode, int? page = null) { - var request = new Request($"discover/{type}", BaseUri, HttpMethod.Get); + var request = new Request($"discover/movie", BaseUri, HttpMethod.Get); request.AddQueryString("api_key", ApiToken); request.AddQueryString("language", langCode); @@ -340,7 +330,27 @@ namespace Ombi.Api.TheMovieDb request.AddQueryString("page", page.ToString()); } await AddDiscoverSettings(request); - await AddGenreFilter(request, type); + await AddGenreFilter(request, "movie"); + AddRetry(request); + var result = await Api.Request>(request); + return Mapper.Map>(result.results); + } + public async Task> UpcomingTv(string langCode, int? page = null) + { + var request = new Request($"discover/tv", BaseUri, HttpMethod.Get); + request.AddQueryString("api_key", ApiToken); + request.AddQueryString("language", langCode); + + // Search for shows that will air in the next month + var startDate = DateTime.Today.AddDays(1); + request.AddQueryString($"first_air_date.gte", startDate.ToString("yyyy-MM-dd")); + request.AddQueryString($"first_air_date.lte", startDate.AddDays(30).ToString("yyyy-MM-dd")); + if (page != null) + { + request.AddQueryString("page", page.ToString()); + } + await AddDiscoverSettings(request); + await AddGenreFilter(request, "tv"); AddRetry(request); var result = await Api.Request>(request); return Mapper.Map>(result.results);