|
|
|
@ -200,19 +200,14 @@ namespace Ombi.Core.Engine.V2
|
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies(int currentPosition, int amountToLoad)
|
|
|
|
|
{
|
|
|
|
|
var langCode = await DefaultLanguageCode(null);
|
|
|
|
|
var isOldTrendingSourceEnabled = await _feature.FeatureEnabled(FeatureNames.OldTrendingSource);
|
|
|
|
|
|
|
|
|
|
var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems);
|
|
|
|
|
|
|
|
|
|
var results = new List<MovieDbSearchResult>();
|
|
|
|
|
foreach (var pagesToLoad in pages)
|
|
|
|
|
{
|
|
|
|
|
var search = () => (isOldTrendingSourceEnabled) ?
|
|
|
|
|
MovieApi.NowPlaying(langCode, pagesToLoad.Page)
|
|
|
|
|
: MovieApi.TrendingMovies(langCode, pagesToLoad.Page);
|
|
|
|
|
|
|
|
|
|
var apiResult = await Cache.GetOrAddAsync(nameof(NowPlayingMovies) + pagesToLoad.Page + langCode,
|
|
|
|
|
search, DateTimeOffset.Now.AddHours(12));
|
|
|
|
|
() => MovieApi.TrendingMovies(langCode, pagesToLoad.Page), DateTimeOffset.Now.AddHours(12));
|
|
|
|
|
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
|
|
|
|
|
}
|
|
|
|
|
return await TransformMovieResultsToResponse(results);
|
|
|
|
|