public async Task <TvShowDetails> GetTvShowDetail(TvShowDetails tvshow) { TMDbClient client = new TMDbClient(ApiKey.tmdbkeyV3, true); TMDbLib.Objects.TvShows.TvShow result = await client.GetTvShowAsync(tvshow.TmdbID, extraMethods : TvShowMethods.Videos | TvShowMethods.ExternalIds, language : CultureInfo.CurrentCulture.TwoLetterISOLanguageName); //| MovieMethods.Credits if (result.Id != 0) { tvshow.ImdbID = result.ExternalIds.ImdbId; tvshow.Synopsis = result.Overview; tvshow.OriginalTitle = result.OriginalName; tvshow.HomePage = result.Homepage; tvshow.Backdrop = result.BackdropPath; if (result.OriginCountry.Count > 0) { tvshow.ProductionCountry = result.OriginCountry.FirstOrDefault(); } else { tvshow.ProductionCountry = ""; } if (result.Videos.Results.Count > 0) { tvshow.Trailer = result.Videos.Results.Where(m => m.Type == "Trailer").Select(t => t.Site == "YouTube" ? "https://www.youtube.com/embed/" + t.Key : t.Key).FirstOrDefault(); } else { tvshow.Trailer = ""; } if (result.Seasons.Count > 0) { List <Episode> episodes = await DB.GetAllEpisodesAsync(tvshow.TmdbID); tvshow.Seasons = result.Seasons.Select(s => new Season { ID = s.Id, N = s.SeasonNumber, TmdbID = tvshow.TmdbID, PersonalRatigAVG = (int)episodes.Where(e => e.SeasonN == s.SeasonNumber).Select(a => a.Rating).Average(), Poster = (s.PosterPath ?? "").Replace("/", ""), EpisodeCount = s.EpisodeCount, EpisodeSeen = episodes.Where(e => e.SeasonN == s.SeasonNumber).Count() }).ToList(); tvshow.SeasonCount = result.Seasons.Count; } else { tvshow.SeasonCount = 0; } tvshow.SeasonSeen = 0; tvshow.Genres = String.Join(" - ", result.Genres.Select(e => e.Name).ToList()); tvshow.Ratings = new List <Rating>(); tvshow.Ratings.Add(new Rating { Source = "TMDB", Value = result.VoteAverage.ToString() }); } return(tvshow); }