public override async Task <bool> UpdateFromOnlineSeriesAsync(SeriesInfo series, TvdbLanguage language, bool cacheOnly) { try { language = language ?? PreferredLanguage; TvdbSeries seriesDetail = null; if (series.TvdbId > 0) { seriesDetail = await _tvdbHandler.GetSeriesAsync(series.TvdbId, language, true, true, false).ConfigureAwait(false); } if (seriesDetail == null && !cacheOnly && !string.IsNullOrEmpty(series.ImdbId)) { TvdbSearchResult foundSeries = await _tvdbHandler.GetSeriesByRemoteIdAsync(ExternalId.ImdbId, series.ImdbId).ConfigureAwait(false); if (foundSeries != null) { seriesDetail = await _tvdbHandler.GetSeriesAsync(foundSeries.Id, language, true, true, false).ConfigureAwait(false); } } if (seriesDetail == null) { return(false); } series.TvdbId = seriesDetail.Id; series.ImdbId = seriesDetail.ImdbId; series.SeriesName = new SimpleTitle(seriesDetail.SeriesName, false); series.FirstAired = seriesDetail.FirstAired; series.Description = new SimpleTitle(seriesDetail.Overview, false); series.Rating = new SimpleRating(seriesDetail.Rating, seriesDetail.RatingCount); series.Genres = seriesDetail.Genre.Where(s => !string.IsNullOrEmpty(s?.Trim())).Select(s => new GenreInfo { Name = s.Trim() }).ToList(); series.Networks = ConvertToCompanies(seriesDetail.NetworkID, seriesDetail.Network, CompanyAspect.COMPANY_TV_NETWORK); if (seriesDetail.Status.IndexOf("Ended", StringComparison.InvariantCultureIgnoreCase) >= 0) { series.IsEnded = true; } CertificationMapping certification = null; if (CertificationMapper.TryFindMovieCertification(seriesDetail.ContentRating, out certification)) { series.Certification = certification.CertificationId; } series.Actors = ConvertToPersons(seriesDetail.TvdbActors, PersonAspect.OCCUPATION_ACTOR, null, seriesDetail.SeriesName); series.Characters = ConvertToCharacters(seriesDetail.TvdbActors, null, seriesDetail.SeriesName); foreach (TvdbActor actor in seriesDetail.TvdbActors) { _seriesToActorMap.StoreMappedId(actor.Id.ToString(), seriesDetail.Id.ToString()); } foreach (TvdbEpisode episodeDetail in seriesDetail.Episodes.OrderByDescending(e => e.Id)) { SeasonInfo seasonInfo = new SeasonInfo() { TvdbId = episodeDetail.SeasonId, SeriesTvdbId = seriesDetail.Id, SeriesImdbId = seriesDetail.ImdbId, SeriesName = new SimpleTitle(seriesDetail.SeriesName, false), SeasonNumber = episodeDetail.SeasonNumber, }; if (!series.Seasons.Contains(seasonInfo)) { series.Seasons.Add(seasonInfo); } EpisodeInfo episodeInfo = new EpisodeInfo() { TvdbId = episodeDetail.Id, SeriesTvdbId = seriesDetail.Id, SeriesImdbId = seriesDetail.ImdbId, SeriesName = new SimpleTitle(seriesDetail.SeriesName, false), SeriesFirstAired = seriesDetail.FirstAired, ImdbId = episodeDetail.ImdbId, SeasonNumber = episodeDetail.SeasonNumber, EpisodeNumbers = new List <int>(new int[] { episodeDetail.EpisodeNumber }), FirstAired = episodeDetail.FirstAired, EpisodeName = new SimpleTitle(episodeDetail.EpisodeName, false), Summary = new SimpleTitle(episodeDetail.Overview, false), Genres = seriesDetail.Genre.Where(s => !string.IsNullOrEmpty(s?.Trim())).Select(s => new GenreInfo { Name = s.Trim() }).ToList(), Rating = new SimpleRating(episodeDetail.Rating, episodeDetail.RatingCount), }; if (episodeDetail.DvdEpisodeNumber > 0) { episodeInfo.DvdEpisodeNumbers = new List <double>(new double[] { episodeDetail.DvdEpisodeNumber }); } episodeInfo.Actors = ConvertToPersons(seriesDetail.TvdbActors, PersonAspect.OCCUPATION_ACTOR, episodeDetail.EpisodeName, seriesDetail.SeriesName); //info.Actors.AddRange(ConvertToPersons(episodeDetail.GuestStars, PersonAspect.OCCUPATION_ACTOR, info.Actors.Count)); episodeInfo.Characters = ConvertToCharacters(seriesDetail.TvdbActors, episodeDetail.EpisodeName, seriesDetail.SeriesName); episodeInfo.Directors = ConvertToPersons(episodeDetail.Directors, PersonAspect.OCCUPATION_DIRECTOR, 0, episodeDetail.EpisodeName, seriesDetail.SeriesName); episodeInfo.Writers = ConvertToPersons(episodeDetail.Writer, PersonAspect.OCCUPATION_WRITER, 0, episodeDetail.EpisodeName, seriesDetail.SeriesName); episodeInfo.Languages.Add(episodeDetail.Language.Abbriviation); if (!series.Episodes.Contains(episodeInfo)) { series.Episodes.Add(episodeInfo); } } series.Episodes.Sort(); series.TotalEpisodes = series.Episodes.Count; for (int index = 0; index < series.Seasons.Count; index++) { series.Seasons[index].FirstAired = series.Episodes.Find(e => e.SeasonNumber == series.Seasons[index].SeasonNumber).FirstAired; series.Seasons[index].TotalEpisodes = series.Episodes.FindAll(e => e.SeasonNumber == series.Seasons[index].SeasonNumber).Count; } series.Seasons.Sort(); series.TotalSeasons = series.Seasons.Count; TvdbEpisode nextEpisode = seriesDetail.Episodes.Where(e => e.FirstAired > DateTime.Now).OrderBy(e => e.FirstAired) .ThenByDescending(p => p.Id).FirstOrDefault(); if (nextEpisode != null) { series.NextEpisodeName = new SimpleTitle(nextEpisode.EpisodeName, false); series.NextEpisodeAirDate = nextEpisode.FirstAired; series.NextEpisodeSeasonNumber = nextEpisode.SeasonNumber; series.NextEpisodeNumber = nextEpisode.EpisodeNumber; } return(true); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Debug("TvDbWrapper: Exception while processing series {0}", ex, series.ToString()); return(false); } }