Fixed #4166 we will now fall back if there are no regional assets to use

pull/4235/head
tidusjar 3 years ago
parent a0cc041449
commit 9389d96e73

@ -64,6 +64,22 @@ namespace Ombi.Core.Engine.V2
return null; return null;
} }
if (!show.Images?.Posters?.Any() ?? false && !string.Equals(langCode, "en", StringComparison.OrdinalIgnoreCase))
{
// There's no regional assets for this, so
// lookup the en-us version to get them
var enShow = await Cache.GetOrAdd(nameof(GetShowInformation) + "en" + tvdbid,
async () => await _movieApi.GetTVInfo(tvdbid, "en"), DateTime.Now.AddHours(12));
// For some of the more obsecure cases
if (!show.overview.HasValue())
{
show.overview = enShow.overview;
}
show.Images = enShow.Images;
}
var mapped = _mapper.Map<SearchFullInfoTvShowViewModel>(show); var mapped = _mapper.Map<SearchFullInfoTvShowViewModel>(show);

@ -32,7 +32,7 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Images, opts => opts.MapFrom(src => src.Images)) .ForMember(dest => dest.Images, opts => opts.MapFrom(src => src.Images))
.ForMember(dest => dest.Cast, opts => opts.MapFrom(src => src.Credits.cast)) .ForMember(dest => dest.Cast, opts => opts.MapFrom(src => src.Credits.cast))
.ForMember(dest => dest.Crew, opts => opts.MapFrom(src => src.Credits.crew)) .ForMember(dest => dest.Crew, opts => opts.MapFrom(src => src.Credits.crew))
.ForMember(dest => dest.Banner, opts => opts.MapFrom(src => GetBanner(src.Images))) .ForMember(dest => dest.Banner, opts => opts.MapFrom(src => GetBanner(src.Images, src.backdrop_path)))
.ForMember(dest => dest.Genres, opts => opts.MapFrom(src => src.genres)) .ForMember(dest => dest.Genres, opts => opts.MapFrom(src => src.genres))
.ForMember(dest => dest.Keywords, opts => opts.MapFrom(src => src.Keywords)) .ForMember(dest => dest.Keywords, opts => opts.MapFrom(src => src.Keywords))
.ForMember(dest => dest.Tagline, opts => opts.MapFrom(src => src.tagline)) .ForMember(dest => dest.Tagline, opts => opts.MapFrom(src => src.tagline))
@ -78,20 +78,20 @@ namespace Ombi.Mapping.Profiles
CreateMap<SearchTvShowViewModel, SearchFullInfoTvShowViewModel>().ReverseMap(); CreateMap<SearchTvShowViewModel, SearchFullInfoTvShowViewModel>().ReverseMap();
} }
private string GetBanner(Api.TheMovieDb.Models.Images images) private string GetBanner(Api.TheMovieDb.Models.Images images, string backdropPath)
{ {
var hasBackdrop = images?.Backdrops?.Any(); var hasBackdrop = images?.Backdrops?.Any();
if (hasBackdrop ?? false) if (hasBackdrop ?? false)
{ {
return images.Backdrops?.OrderBy(x => x.VoteCount).ThenBy(x => x.VoteAverage).Select(x => x.FilePath).FirstOrDefault(); return images.Backdrops?.OrderBy(x => x.VoteCount).ThenBy(x => x.VoteAverage).Select(x => x.FilePath).FirstOrDefault();
} }
else if (images != null) else if (images?.Posters?.Any() ?? false)
{ {
return images.Posters?.OrderBy(x => x.VoteCount).ThenBy(x => x.VoteAverage).Select(x => x.FilePath).FirstOrDefault(); return images.Posters?.OrderBy(x => x.VoteCount).ThenBy(x => x.VoteAverage).Select(x => x.FilePath).FirstOrDefault();
} }
else else
{ {
return string.Empty; return backdropPath;
} }
} }

Loading…
Cancel
Save