mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Call abstract ProcessResult from generic one while searching TV
This especially allows to execute search rules, and therefor to fill properties like requested, approved and available statuses
This commit is contained in:
parent
8eb29ab905
commit
56948035f9
2 changed files with 12 additions and 11 deletions
|
@ -56,7 +56,7 @@ namespace Ombi.Core.Engine.Demo
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
retVal.Add(ProcessResult(tvMazeSearch));
|
retVal.Add(await ProcessResult(tvMazeSearch));
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ namespace Ombi.Core.Engine.Demo
|
||||||
}
|
}
|
||||||
|
|
||||||
var movieResult = await TvMazeApi.ShowLookup(tv);
|
var movieResult = await TvMazeApi.ShowLookup(tv);
|
||||||
responses.Add(ProcessResult(movieResult));
|
responses.Add(await ProcessResult(movieResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
return responses;
|
return responses;
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
retVal.Add(ProcessResult(tvMazeSearch));
|
retVal.Add(await ProcessResult(tvMazeSearch));
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ namespace Ombi.Core.Engine
|
||||||
public async Task<IEnumerable<SearchTvShowViewModel>> Popular()
|
public async Task<IEnumerable<SearchTvShowViewModel>> Popular()
|
||||||
{
|
{
|
||||||
var result = await Cache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
var result = await Cache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
||||||
var processed = ProcessResults(result);
|
var processed = await ProcessResults(result);
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,37 +131,38 @@ namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
|
|
||||||
var result = await Cache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
var result = await Cache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
||||||
var processed = ProcessResults(result);
|
var processed = await ProcessResults(result);
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
||||||
{
|
{
|
||||||
var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
||||||
var processed = ProcessResults(result);
|
var processed = await ProcessResults(result);
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||||
{
|
{
|
||||||
var result = await Cache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
var result = await Cache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
||||||
var processed = ProcessResults(result);
|
var processed = await ProcessResults(result);
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IEnumerable<SearchTvShowViewModel> ProcessResults<T>(IEnumerable<T> items)
|
protected async Task<IEnumerable<SearchTvShowViewModel>> ProcessResults<T>(IEnumerable<T> items)
|
||||||
{
|
{
|
||||||
var retVal = new List<SearchTvShowViewModel>();
|
var retVal = new List<SearchTvShowViewModel>();
|
||||||
foreach (var tvMazeSearch in items)
|
foreach (var tvMazeSearch in items)
|
||||||
{
|
{
|
||||||
retVal.Add(ProcessResult(tvMazeSearch));
|
retVal.Add(await ProcessResult(tvMazeSearch));
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SearchTvShowViewModel ProcessResult<T>(T tvMazeSearch)
|
protected async Task<SearchTvShowViewModel> ProcessResult<T>(T tvMazeSearch)
|
||||||
{
|
{
|
||||||
return Mapper.Map<SearchTvShowViewModel>(tvMazeSearch);
|
var viewTv = Mapper.Map<SearchTvShowViewModel>(tvMazeSearch);
|
||||||
|
return await ProcessResult(viewTv);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<SearchTvShowViewModel> ProcessResult(SearchTvShowViewModel item)
|
private async Task<SearchTvShowViewModel> ProcessResult(SearchTvShowViewModel item)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue