예제 #1
0
        private static void SetSeasons(Show show, TVDBSharp.Models.Show fetchedShow)
        {
            ICollection<Season> seasons = show.Seasons;

            foreach (TVDBSharp.Models.Episode episodeModel in fetchedShow.Episodes)
            {
                int seasonNumber = episodeModel.SeasonNumber;

                Season season = seasons.FirstOrDefault(s => s.Number == seasonNumber);

                if (season == null)
                {
                    season = new Season
                    {
                        Number = seasonNumber
                    };

                    seasons.Add(season);
                }

                TVDBSharp.Models.Episode model = episodeModel;

                Episode episode = season.Episodes.FirstOrDefault(e => e.Number == model.EpisodeNumber);

                if (episode == null)
                {
                    episode = new Episode();
                }

                MapEpisode(episode, episodeModel);

                episode.Season = season;
                season.Episodes.Add(episode);

                show.Seasons.Add(season);
                season.Show = show;
            }
        }
예제 #2
0
        private void MapShow(Show show, TVDBSharp.Models.Show fetchedShow)
        {
            show.AirTime = fetchedShow.AirTime;
            show.Runtime = fetchedShow.Runtime;
            show.Description = GetDescription(fetchedShow.Description);
            show.Network = this.GetOrCreateNetwork(fetchedShow.Network);
            show.TvDbId = fetchedShow.Id;
            show.ImdbId = fetchedShow.ImdbId;
            show.Language = GetLanguage(fetchedShow.Language);
            show.AirDay = GetAirDay(fetchedShow.AirDay);
            show.FirstAired = fetchedShow.FirstAired;
            this.AddGenres(show.Genres, fetchedShow.Genres);
            show.LastUpdated = fetchedShow.LastUpdated;
            show.Name = fetchedShow.Name;
            show.Status = GetStatus(fetchedShow.Status);
            show.BannerBig = this.GetImage("big_", fetchedShow.Banner, this.AppSettings.BannerDirectory);
            show.PosterBig = this.GetImage("big_", fetchedShow.Poster, this.AppSettings.PosterDirectory);
            show.UserFriendlyId = GetUserFriendlyId(fetchedShow.Name);

            show.Network.Shows.Add(show);

            SetSeasons(show, fetchedShow);
        }
예제 #3
0
 private static void MapEpisode(Episode episode, TVDBSharp.Models.Episode episodeModel)
 {
     episode.ImdbId = episodeModel.ImdbId;
     episode.TvDbId = episodeModel.Id;
     episode.FirstAired = episodeModel.FirstAired;
     episode.Description = episodeModel.Description;
     episode.LastUpdated = episodeModel.LastUpdated;
     episode.Number = episodeModel.EpisodeNumber;
     episode.Title = episodeModel.Title;
 }