Skip to content

Commit

Permalink
Merge branch 'develop-test' of https://github.com/tidusjar/Ombi into …
Browse files Browse the repository at this point in the history
…develop-test
  • Loading branch information
twanariens committed Jan 23, 2021
2 parents 985479f + 598c0cf commit bad06f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
23 changes: 15 additions & 8 deletions src/Ombi.Core/Engine/TvSearchEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ public async Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm)
{
continue;
}
retVal.Add(await ProcessResult(tvMazeSearch, false));
var mappedResult = await ProcessResult(tvMazeSearch, false);
if (mappedResult == null)
{
continue;
}
retVal.Add(mappedResult);
}
return retVal;
}
Expand Down Expand Up @@ -194,7 +199,7 @@ protected async Task<IEnumerable<SearchTvShowViewModel>> ProcessResults<T>(IEnum
foreach (var tvMazeSearch in items)
{
var result = await ProcessResult(tvMazeSearch, includeImages);
if(settings.HideAvailableFromDiscover && result.Available)
if (result == null || settings.HideAvailableFromDiscover && result.Available)
{
continue;
}
Expand All @@ -211,15 +216,17 @@ protected async Task<SearchTvShowViewModel> ProcessResult<T>(T tvMazeSearch, boo

private async Task<SearchTvShowViewModel> ProcessResult(SearchTvShowViewModel item, bool includeImages)
{
if (item.Id == 0)
{
return null;
}
item.TheTvDbId = item.Id.ToString();
if (includeImages)
{

if (item.TheTvDbId.HasValue())
{
item.BackdropPath = await _imageService.GetTvBackground(item.TheTvDbId);
}

if (item.TheTvDbId.HasValue())
{
item.BackdropPath = await _imageService.GetTvBackground(item.TheTvDbId);
}
}

await RunSearchRules(item);
Expand Down
6 changes: 3 additions & 3 deletions src/Ombi.Mapping/Profiles/TvProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public TvProfile()


CreateMap<TraktShow, SearchTvShowViewModel>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => Convert.ToInt32(src.Ids.Tvdb.ToString())))
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.Ids.Tvdb.HasValue ? Convert.ToInt32(src.Ids.Tvdb.ToString()) : 0))
.ForMember(dest => dest.FirstAired, opts => opts.MapFrom(src => src.FirstAired.HasValue ? src.FirstAired.Value.ToString("yyyy-MM-ddTHH:mm:ss") : string.Empty))
.ForMember(dest => dest.ImdbId, opts => opts.MapFrom(src => src.Ids.Imdb))
.ForMember(dest => dest.Network, opts => opts.MapFrom(src => src.Network))
Expand All @@ -57,9 +57,9 @@ public TvProfile()
.ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.Title))
.ForMember(dest => dest.Status, opts => opts.MapFrom(src => TraktEnumHelper.GetDescription(src.Status)))
.ForMember(dest => dest.Trailer,
opts => opts.MapFrom(src => src.Trailer.ToString().ToHttpsUrl()))
opts => opts.MapFrom(src => src.Trailer != null ? src.Trailer.ToString().ToHttpsUrl() : string.Empty))
.ForMember(dest => dest.Homepage,
opts => opts.MapFrom(src => src.Homepage.ToString().ToHttpsUrl()));
opts => opts.MapFrom(src => src.Homepage != null ? src.Homepage.ToString().ToHttpsUrl() : string.Empty));
}
}
}

0 comments on commit bad06f9

Please sign in to comment.