Exemplo n.º 1
0
        public async void Tmdb_GetShowInfo_ASearchResult()
        {
            var tmdb = new TmdbOnlineDataCollector();
            var first = await tmdb.SearchName("Marvel");
            var result = await tmdb.GetShowInfo(first.First().TmdbId);

            Assert.IsNotNull(result.NumberOfSeasons);
        }
Exemplo n.º 2
0
        public async Task UpdateAElementOnTheList(String id)
        {
            if (TvSeries.Exists(show => show.TmdbId == id && ((DateTime.Now.TimeOfDay - show.LastUpdated.TimeOfDay) >= TimeSpan.FromHours(1) || show.LastUpdated.Date != DateTime.Today)))
            {
                var collector = new TmdbOnlineDataCollector();
                var showInfo = await collector.GetShowInfo(id);

                var seasonInfo = await collector.GetSeasonInfo(id, showInfo.NumberOfSeasons);

                foreach (var tvSerie in TvSeries.Where(show => show.TmdbId == id))
                {
                    foreach (var searchSeasonResult in seasonInfo)
                    {
                        if (!tvSerie.Seasons.Exists(season => season.Number == searchSeasonResult.Number))
                        {
                            var season = new Season(searchSeasonResult.Number) {AirDate = searchSeasonResult.AirDate};

                            foreach (var searchEpisode in searchSeasonResult.Episodes)
                            {
                                season.Episodes.Add(new Episode(searchEpisode.Number)
                                {
                                    Title = searchEpisode.Title,
                                    AirDate = searchEpisode.AirDate
                                });
                            }
                            tvSerie.Seasons.Add(season);
                        }
                        else
                        {
                            foreach (var searchSeasonResultEpisode in searchSeasonResult.Episodes)
                            {
                                if (!tvSerie.Seasons.Find(season => season.Number == searchSeasonResult.Number)
                                        .Episodes.Exists(episode => episode.Number == searchSeasonResultEpisode.Number))
                                {
                                    var episode = new Episode(searchSeasonResultEpisode.Number)
                                    {
                                        Title = searchSeasonResultEpisode.Title,
                                        AirDate = searchSeasonResult.AirDate
                                    };
                                    tvSerie.Seasons.Find(season => season.Number == searchSeasonResult.Number).Episodes.Add(episode);
                                }
                                else
                                {
                                    var refEpisode = tvSerie.Seasons.Find(
                                        season => season.Number == searchSeasonResult.Number)
                                        .Episodes.Find(episode => episode.Number == searchSeasonResultEpisode.Number);
                                    
                                    refEpisode.Title = searchSeasonResultEpisode.Title;
                                    refEpisode.AirDate = searchSeasonResultEpisode.AirDate;
                                }
                            }
                        }
                    }
                }

                TvSeries.Find(show => show.TmdbId == id).LastUpdated = DateTime.Now;
                await Save();
            }
        }