public async Task <SearchFullInfoTvShowViewModel> GetShowInformation(string tvdbid, CancellationToken token) { var langCode = await DefaultLanguageCode(null); var show = await Cache.GetOrAddAsync(nameof(GetShowInformation) + langCode + tvdbid, async() => await _movieApi.GetTVInfo(tvdbid, langCode), DateTimeOffset.Now.AddHours(12)); if (show == null || show.name == null) { // We don't have enough information 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.GetOrAddAsync(nameof(GetShowInformation) + "en" + tvdbid, async() => await _movieApi.GetTVInfo(tvdbid, "en"), DateTimeOffset.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); foreach (var tvSeason in show.seasons.Where(x => x.season_number != 0)) // skip the first season { var seasonEpisodes = (await _movieApi.GetSeasonEpisodes(show.id, tvSeason.season_number, token)); MapSeasons(mapped.SeasonRequests, tvSeason, seasonEpisodes); } return(await ProcessResult(mapped)); }
public async Task <SearchFullInfoTvShowViewModel> GetShowInformation(string tvdbid, CancellationToken token) { var show = await Cache.GetOrAdd(nameof(GetShowInformation) + tvdbid, async() => await _movieApi.GetTVInfo(tvdbid), DateTime.Now.AddHours(12)); if (show == null || show.name == null) { // We don't have enough information return(null); } var mapped = _mapper.Map <SearchFullInfoTvShowViewModel>(show); foreach (var tvSeason in show.seasons.Where(x => x.season_number != 0)) // skip the first season { var seasonEpisodes = (await _movieApi.GetSeasonEpisodes(show.id, tvSeason.season_number, token)); MapSeasons(mapped.SeasonRequests, tvSeason, seasonEpisodes); } return(await ProcessResult(mapped)); }