示例#1
0
        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);
        }
示例#2
0
        public async Task <int> CheckAndUpdateSeasonCounter(TvShowDetails tvshow)
        {
            int n = 0;

            //if there is a new season update season number and so make tvshow unseen
            if (tvshow.SeasonCount < tvshow.Seasons.Count)
            {
                tvshow.SeasonCount = tvshow.Seasons.Count;
                n = await DB.UpdateTvShowAsync(new TvShow((TvShow)tvshow));
            }

            //if all episode of season are seen update number in tvshow
            int SeasonSeen = tvshow.Seasons.Where(s => s.EpisodeCount == s.EpisodeSeen).Count();

            if (SeasonSeen > tvshow.SeasonSeen)
            {
                tvshow.SeasonSeen = SeasonSeen;
                n = await DB.UpdateTvShowAsync(new TvShow((TvShow)tvshow));
            }

            return(n);
        }
示例#3
0
        public async Task <int> GetDetail()
        {
            TvShowDet = await DE.GetTvShowDetail(TvShowDet);

            return(1);
        }
示例#4
0
 public TvShowCardModel(TvShow tvshow)
 {
     DE = new DataExchange();
     //Get movie base data from the class movie selected
     TvShowDet = new TvShowDetails(tvshow);
 }