Beispiel #1
0
        protected Show LoadUpAShow(String fileName, String filePath, int showSeasonNr, int showEpisodeNr, String tvSerieName)
        {
            var tmpTvSerieName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(tvSerieName);

            if (String.IsNullOrEmpty(tmpTvSerieName))
                return null;

            var episode = new Episode(showEpisodeNr, filePath);
            var season = new Season(showSeasonNr);
            season.Episodes.Add(episode);
            var show = new Show(tmpTvSerieName);
            show.Seasons.Add(season);

            return show;
        }
Beispiel #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();
            }
        }