Skip to content

Commit

Permalink
Fixed #2475
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Aug 28, 2018
1 parent 9b3bd1b commit 0ff920f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Ombi.Core/Engine/TvSearchEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ public async Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm)

if (searchResult != null)
{
return await ProcessResults(searchResult);
var retVal = new List<SearchTvShowViewModel>();
foreach (var tvMazeSearch in searchResult)
{
if (tvMazeSearch.show.externals == null || !(tvMazeSearch.show.externals?.thetvdb.HasValue ?? false))
{
continue;
}
retVal.Add(await ProcessResult(tvMazeSearch));
}
return retVal;
}
return null;
}
Expand Down Expand Up @@ -145,12 +154,16 @@ private async Task<IEnumerable<SearchTvShowViewModel>> ProcessResults<T>(IEnumer
var retVal = new List<SearchTvShowViewModel>();
foreach (var tvMazeSearch in items)
{
var viewT = Mapper.Map<SearchTvShowViewModel>(tvMazeSearch);
retVal.Add(await ProcessResult(viewT));
retVal.Add(await ProcessResult(tvMazeSearch));
}
return retVal;
}

private async Task<SearchTvShowViewModel> ProcessResult<T>(T tvMazeSearch)
{
return Mapper.Map<SearchTvShowViewModel>(tvMazeSearch);
}

private async Task<SearchTvShowViewModel> ProcessResult(SearchTvShowViewModel item)
{
item.TheTvDbId = item.Id.ToString();
Expand Down

0 comments on commit 0ff920f

Please sign in to comment.