/// <summary>
        /// Update all fields of the object with the given information
        /// </summary>
        /// <param name="fields">the fields for the update</param>
        /// <param name="replaceEpisodes">Should the episodes be replaced or kept</param>
        internal void UpdateTvdbFields(TvdbSeriesFields fields, bool replaceEpisodes)
        {
            //Update series details
            Id            = fields.Id;
            Actors        = fields.Actors;
            AirsDayOfWeek = fields.AirsDayOfWeek;
            AirsTime      = fields.AirsTime;
            ContentRating = fields.ContentRating;
            FirstAired    = fields.FirstAired;
            Genre         = fields.Genre;
            ImdbId        = fields.ImdbId;
            Language      = fields.Language;
            Network       = fields.Network;
            NetworkID     = fields.NetworkID;
            Overview      = fields.Overview;
            Rating        = fields.Rating;
            RatingCount   = fields.RatingCount;
            Runtime       = fields.Runtime;
            TvDotComId    = fields.TvDotComId;
            SeriesName    = fields.SeriesName;
            Status        = fields.Status;
            BannerPath    = fields.BannerPath;
            FanartPath    = fields.FanartPath;
            PosterPath    = fields.PosterPath;
            LastUpdated   = fields.LastUpdated;
            Zap2itId      = fields.Zap2itId;

            if (replaceEpisodes)
            {
                if (Episodes != null && fields.EpisodesLoaded)
                {
                    //check for each episode if episode images have been loaded...
                    //if yes -> copy image
                    foreach (TvdbEpisode f in fields.Episodes)
                    {
                        foreach (TvdbEpisode e in Episodes)
                        {
                            if (e.Id == f.Id && e.Banner != null && e.Banner.IsLoaded)
                            {
                                f.Banner = e.Banner;
                                break;
                            }
                        }
                    }
                }
                EpisodesLoaded = fields.EpisodesLoaded;
                if (Episodes == null)
                {
                    Episodes = new UniqueList <TvdbEpisode>();
                }
                else
                {
                    Episodes.Clear();
                }
                Episodes.AddRange(fields.Episodes);
            }
        }
Ejemplo n.º 2
0
        internal void SetEpisodes(List <TvdbEpisode> episodes)
        {
            foreach (KeyValuePair <TvdbLanguage, TvdbSeriesFields> kvp in _seriesTranslations)
            {
                if (kvp.Key.Abbriviation.Equals(Language.Abbriviation))
                {
                    kvp.Value.EpisodesLoaded = true;
                    kvp.Value.Episodes.Clear();
                    kvp.Value.Episodes.AddRange(episodes);
                }
            }

            EpisodesLoaded = true;
            Episodes.Clear();
            Episodes.AddRange(episodes);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Update the info of the current series with the updated one
        /// </summary>
        /// <param name="series">TvdbSeries object</param>
        protected void UpdateSeriesInfo(TvdbSeries series)
        {
            Actors        = series.Actors;
            AirsDayOfWeek = series.AirsDayOfWeek;
            AirsTime      = series.AirsTime;
            BannerPath    = series.BannerPath;
            Banners       = series.Banners;
            ContentRating = series.ContentRating;
            FanartPath    = series.FanartPath;
            FirstAired    = series.FirstAired;
            Genre         = series.Genre;
            Id            = series.Id;
            ImdbId        = series.ImdbId;
            Language      = series.Language;
            LastUpdated   = series.LastUpdated;
            Network       = series.Network;
            Overview      = series.Overview;
            Rating        = series.Rating;
            Runtime       = series.Runtime;
            SeriesName    = series.SeriesName;
            Status        = series.Status;
            TvDotComId    = series.TvDotComId;
            Zap2itId      = series.Zap2itId;

            if (series.EpisodesLoaded)
            {//check if the old series has any images loaded already -> if yes, save them
                if (EpisodesLoaded)
                {
                    foreach (TvdbEpisode oe in Episodes)
                    {
                        foreach (TvdbEpisode ne in series.Episodes)
                        {
                            if (oe.SeasonNumber == ne.SeasonNumber &&
                                oe.EpisodeNumber == ne.EpisodeNumber)
                            {
                                if (oe.Banner != null && oe.Banner.IsLoaded)
                                {
                                    ne.Banner = oe.Banner;
                                }
                            }
                        }
                    }
                }

                Episodes.Clear();
                Episodes.AddRange(series.Episodes);
            }

            if (series.TvdbActorsLoaded)
            {//check if the old series has any images loaded already -> if yes, save them
                if (TvdbActorsLoaded)
                {
                    foreach (TvdbActor oa in TvdbActors)
                    {
                        foreach (TvdbActor na in series.TvdbActors)
                        {
                            if (oa.Id == na.Id)
                            {
                                if (oa.ActorImage != null && oa.ActorImage.IsLoaded)
                                {
                                    na.ActorImage = oa.ActorImage;
                                }
                            }
                        }
                    }
                }
                TvdbActors = series.TvdbActors;
            }

            if (series.BannersLoaded)
            {
                //check if the old series has any images loaded already -> if yes, save them
                if (BannersLoaded)
                {
                    foreach (TvdbBanner ob in Banners)
                    {
                        foreach (TvdbBanner nb in series.Banners)
                        {
                            if (ob.BannerPath.Equals(nb.BannerPath))//I have to check for the banner path since the Update file doesn't include IDs
                            {
                                if (ob.BannerImage != null && ob.IsLoaded)
                                {
                                    nb.BannerImage = ob.BannerImage;
                                }

                                if (ob.GetType() == typeof(TvdbFanartBanner))
                                {
                                    TvdbFanartBanner newFaBanner = (TvdbFanartBanner)nb;
                                    TvdbFanartBanner oldFaBanner = (TvdbFanartBanner)ob;

                                    if (oldFaBanner.ThumbImage != null && oldFaBanner.IsThumbLoaded)
                                    {
                                        newFaBanner.ThumbImage = oldFaBanner.ThumbImage;
                                    }

                                    if (oldFaBanner.ThumbImage != null && oldFaBanner.IsVignetteLoaded)
                                    {
                                        newFaBanner.VignetteImage = oldFaBanner.VignetteImage;
                                    }
                                }
                            }
                        }
                    }
                }
                Banners = series.Banners;
            }
        }