Esempio n. 1
0
        /// <summary>
        /// Update the series with the banner
        /// </summary>
        /// <param name="_series"></param>
        /// <param name="_banner"></param>
        private void UpdateBanner(TvdbSeries _series, TvdbBanner _banner)
        {
            if (!_series.BannersLoaded)
            {//banners for this series havn't been loaded -> don't update banners
                return;
            }
            bool found = false;

            foreach (TvdbBanner b in _series.Banners)
            {
                if (_banner.GetType() == b.GetType() && _banner.BannerPath.Equals(b.BannerPath))
                {
                    if (b.LastUpdated < _banner.LastUpdated)
                    {
                        b.LastUpdated = _banner.LastUpdated;
                        if (_banner.GetType() == typeof(TvdbFanartBanner))
                        {
                            TvdbFanartBanner fanart = (TvdbFanartBanner)b;

                            fanart.Resolution = ((TvdbFanartBanner)_banner).Resolution;
                            if (fanart.IsThumbLoaded)
                            {
                                fanart.LoadThumb(null);
                            }

                            if (fanart.IsVignetteLoaded)
                            {
                                fanart.LoadVignette(null);
                            }
                        }
                        if (b.IsLoaded)
                        {
                            b.LoadBanner(null);
                        }

                        Log.Info("Replacing banner " + _banner.Id);
                    }
                    else
                    {
                        Log.Debug("Not replacing banner " + _banner.Id + " because it's not newer than current image");
                    }
                    found = true;
                }
            }
            if (!found)
            {//banner not found -> add it to bannerlist
                Log.Info("Adding banner " + _banner.Id);
                _series.Banners.Add(_banner);
            }
        }
Esempio n. 2
0
        private void pb3_Click(object sender, EventArgs e)
        {
            if (m_items == null)
            {
                return;
            }
            TvdbFanartBanner banner = m_items[m_currentIndex + 3];

            if (banner.IsLoaded || banner.LoadBanner())
            {
                pbFull.Image = banner.Banner;
            }
            else
            {
                pbFull.Image = pbFull.ErrorImage;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Create the series banner content
        /// </summary>
        /// <param name="bannerList">List of banners to store</param>
        /// <returns>xml content</returns>
        internal String CreateSeriesBannerContent(List <TvdbBanner> bannerList)
        {
            XElement xml = new XElement("Banners");

            foreach (TvdbBanner b in bannerList)
            {
                XElement banner = new XElement("Banner");
                banner.Add(new XElement("id", b.Id));
                banner.Add(new XElement("BannerPath", b.BannerPath));
                banner.Add(new XElement("LastUpdated", Util.DotNetToUnix(b.LastUpdated)));
                if (b.GetType() == typeof(TvdbSeriesBanner))
                {
                    TvdbSeriesBanner sb = (TvdbSeriesBanner)b;
                    banner.Add(new XElement("BannerType", "series"));
                    banner.Add(new XElement("BannerType2", sb.BannerType));
                    banner.Add(new XElement("Language", (sb.Language != null ? sb.Language.Abbriviation : "")));
                }
                else if (b.GetType() == typeof(TvdbFanartBanner))
                {
                    TvdbFanartBanner fb = (TvdbFanartBanner)b;
                    banner.Add(new XElement("BannerType", "fanart"));
                    banner.Add(new XElement("BannerType2", fb.Resolution.X + "x" + fb.Resolution.Y));
                    if (fb.Colors != null && fb.Colors.Count == 0)
                    {
                        StringBuilder colorString = new StringBuilder();
                        colorString.Append("|");
                        foreach (Color c in fb.Colors)
                        {
                            colorString.Append(c.R);
                            colorString.Append(",");
                            colorString.Append(c.G);
                            colorString.Append(",");
                            colorString.Append(c.B);
                            colorString.Append("|");
                        }
                        banner.Add(new XElement("Colors", colorString.ToString()));
                    }
                    else
                    {
                        banner.Add(new XElement("Colors", ""));
                    }
                    banner.Add(new XElement("VignettePath", fb.VignettePath));
                    banner.Add(new XElement("ThumbnailPath", fb.ThumbPath));
                    banner.Add(new XElement("Language", (fb.Language != null ? fb.Language.Abbriviation : "")));
                    banner.Add(new XElement("SeriesName", fb.ContainsSeriesName.ToString()));
                }
                else if (b.GetType() == typeof(TvdbSeasonBanner))
                {
                    TvdbSeasonBanner sb = (TvdbSeasonBanner)b;
                    banner.Add(new XElement("BannerType", "Season"));
                    banner.Add(new XElement("BannerType2", sb.BannerType));
                    banner.Add(new XElement("Language", (sb.Language != null ? sb.Language.Abbriviation : "")));
                    banner.Add(new XElement("Season", sb.Season));
                }
                else if (b.GetType() == typeof(TvdbPosterBanner))
                {
                    TvdbPosterBanner pb = (TvdbPosterBanner)b;
                    banner.Add(new XElement("BannerType", "Poster"));
                    banner.Add(new XElement("BannerType2", pb.Resolution.X + "x" + pb.Resolution.Y));
                    banner.Add(new XElement("Language", (pb.Language != null ? pb.Language.Abbriviation : "")));
                }
                else
                {
                    //this shouldn't happen, it's an invalid banner type (maybe new?) -> don't store it
                    continue;
                }
                xml.Add(banner);
            }

            return(xml.ToString());
        }
Esempio n. 4
0
        /// <summary>
        /// Uptdate the info of the current series with the updated one
        /// </summary>
        /// <param name="_series">TvdbSeries object</param>
        protected void UpdateSeriesInfo(TvdbSeries _series)
        {
            this.Actors        = _series.Actors;
            this.AirsDayOfWeek = _series.AirsDayOfWeek;
            this.AirsTime      = _series.AirsTime;
            this.BannerPath    = _series.BannerPath;
            this.Banners       = _series.Banners;
            this.ContentRating = _series.ContentRating;
            this.FanartPath    = _series.FanartPath;
            this.FirstAired    = _series.FirstAired;
            this.Genre         = _series.Genre;
            this.Id            = _series.Id;
            this.ImdbId        = _series.ImdbId;
            this.Language      = _series.Language;
            this.LastUpdated   = _series.LastUpdated;
            this.Network       = _series.Network;
            this.Overview      = _series.Overview;
            this.Rating        = _series.Rating;
            this.Runtime       = _series.Runtime;
            this.SeriesName    = _series.SeriesName;
            this.Status        = _series.Status;
            this.TvDotComId    = _series.TvDotComId;
            this.Zap2itId      = _series.Zap2itId;

            if (_series.EpisodesLoaded)
            {//check if the old series has any images loaded already -> if yes, save them
                if (this.EpisodesLoaded)
                {
                    foreach (TvdbEpisode oe in this.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;
                                }
                            }
                        }
                    }
                }

                this.Episodes = _series.Episodes;
            }

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

            if (_series.BannersLoaded)
            {
                //check if the old series has any images loaded already -> if yes, save them
                if (this.BannersLoaded)
                {
                    foreach (TvdbBanner ob in this.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;
                                    }
                                }
                            }
                        }
                    }
                }
                this.Banners = _series.Banners;
            }
        }