Beispiel #1
0
        private List <PosterSeason> GetPosterSeason(XmlNode aNode, string aSeriesID, string aSeriesName, ref List <string> aSeasons)
        {
            var lPosters = new List <PosterSeason>();

            foreach (XmlNode banner in aNode.SelectNodes("/Banners/Banner[BannerType='season']"))
            {
                var lSeasonPoster = new PosterSeason();

                lSeasonPoster.Language        = banner.SelectSingleNode("Language").InnerText;
                lSeasonPoster.OnlinePath      = banner.SelectSingleNode("BannerPath").InnerText;
                lSeasonPoster.OnlineThumbPath = banner.SelectSingleNode("ThumbnailPath").InnerText;
                lSeasonPoster.SeasonIndex     = banner.SelectSingleNode("Season").InnerText;
                lSeasonPoster.SeriesName      = aSeriesName;

                try
                {
                    lSeasonPoster.Style = ( ArtworkStyles )Enum.Parse(typeof(ArtworkStyles), banner.SelectSingleNode("BannerType2").InnerText, true);
                }
                catch
                {
                    // maybe a new style introduced
                    lSeasonPoster.Style = ArtworkStyles.unknown;
                }

                if (!string.IsNullOrEmpty(banner.SelectSingleNode("Rating").InnerText))
                {
                    double rating = double.Parse(banner.SelectSingleNode("Rating").InnerText, NumberStyles.Any, NumberFormatInfo.InvariantInfo);
                    lSeasonPoster.Rating = Math.Round(rating, 1, MidpointRounding.AwayFromZero);
                }

                if (!string.IsNullOrEmpty(banner.SelectSingleNode("RatingCount").InnerText))
                {
                    lSeasonPoster.RatingCount = int.Parse(banner.SelectSingleNode("RatingCount").InnerText);
                }

                if (!aSeasons.Contains(lSeasonPoster.SeasonIndex))
                {
                    aSeasons.Add(lSeasonPoster.SeasonIndex);
                }

                lSeasonPoster.SeriesID = aSeriesID;
                lPosters.Add(lSeasonPoster);
            }

            return(lPosters);
        }
Beispiel #2
0
        private void doWork(string seriesID)
        {
            XmlNode banners = OnlineAPI.getBannerList(Int32.Parse(seriesID));

            if (banners == null)
            {
                return;
            }

            if (Helper.getCorrespondingSeries(Int32.Parse(seriesID)) == null)
            {
                return;
            }

            string SeriesName = Helper.getCorrespondingSeries(Int32.Parse(seriesID)).ToString();
            List <WideBannerSeries> widebannerSeriesList = new List <WideBannerSeries>();
            List <PosterSeries>     posterSeriesList     = new List <PosterSeries>();
            List <PosterSeason>     posterSeasonList     = new List <PosterSeason>();
            SeriesBannersMap        map = new SeriesBannersMap();

            map.SeriesID = seriesID;

            #region Series WideBanners
            foreach (XmlNode banner in banners.SelectNodes("/Banners/Banner[BannerType='series']"))
            {
                WideBannerSeries seriesWideBanners = new WideBannerSeries();

                seriesWideBanners.Language   = banner.SelectSingleNode("Language").InnerText;
                seriesWideBanners.OnlinePath = banner.SelectSingleNode("BannerPath").InnerText;
                seriesWideBanners.SeriesName = SeriesName;

                try
                {
                    seriesWideBanners.Style = (ArtworkStyles)Enum.Parse(typeof(ArtworkStyles), banner.SelectSingleNode("BannerType2").InnerText, true);
                }
                catch
                {
                    // maybe a new style introduced
                    seriesWideBanners.Style = ArtworkStyles.unknown;
                }

                if (!string.IsNullOrEmpty(banner.SelectSingleNode("Rating").InnerText))
                {
                    double rating = double.Parse(banner.SelectSingleNode("Rating").InnerText, NumberStyles.Any, NumberFormatInfo.InvariantInfo);
                    seriesWideBanners.Rating = Math.Round(rating, 1, MidpointRounding.AwayFromZero);
                }

                if (!string.IsNullOrEmpty(banner.SelectSingleNode("RatingCount").InnerText))
                {
                    seriesWideBanners.RatingCount = int.Parse(banner.SelectSingleNode("RatingCount").InnerText);
                }

                seriesWideBanners.SeriesID = seriesID;
                widebannerSeriesList.Add(seriesWideBanners);
            }
            // sort by highest rated
            widebannerSeriesList.Sort();

            // remove banners of no interest
            if (!DBOption.GetOptions(DBOption.cGetTextBanners))
            {
                widebannerSeriesList.RemoveAll(b => b.Style == ArtworkStyles.text);
            }
            if (!DBOption.GetOptions(DBOption.cGetBlankBanners))
            {
                widebannerSeriesList.RemoveAll(b => b.Style == ArtworkStyles.blank);
            }

            // Respect User Limits, exception: if higher rated image or localised image is uploaded online
            int limit = DBOption.GetOptions(DBOption.cArtworkLimitSeriesWideBanners);
            if (limit < widebannerSeriesList.Count)
            {
                widebannerSeriesList.RemoveRange(limit, widebannerSeriesList.Count - limit);
            }

            map.SeriesWideBanners = widebannerSeriesList;
            #endregion

            #region Series Posters
            foreach (XmlNode banner in banners.SelectNodes("/Banners/Banner[BannerType='poster']"))
            {
                PosterSeries seriesPoster = new PosterSeries();

                seriesPoster.Language   = banner.SelectSingleNode("Language").InnerText;
                seriesPoster.OnlinePath = banner.SelectSingleNode("BannerPath").InnerText;
                seriesPoster.SeriesName = SeriesName;

                if (!string.IsNullOrEmpty(banner.SelectSingleNode("Rating").InnerText))
                {
                    double rating = double.Parse(banner.SelectSingleNode("Rating").InnerText, NumberStyles.Any, NumberFormatInfo.InvariantInfo);
                    seriesPoster.Rating = Math.Round(rating, 1, MidpointRounding.AwayFromZero);
                }

                if (!string.IsNullOrEmpty(banner.SelectSingleNode("RatingCount").InnerText))
                {
                    seriesPoster.RatingCount = int.Parse(banner.SelectSingleNode("RatingCount").InnerText);
                }

                seriesPoster.SeriesID = seriesID;
                posterSeriesList.Add(seriesPoster);
            }

            posterSeasonList.Sort();

            limit = DBOption.GetOptions(DBOption.cArtworkLimitSeriesPosters);
            if (limit < posterSeriesList.Count)
            {
                posterSeriesList.RemoveRange(limit, posterSeriesList.Count - limit);
            }

            map.SeriesPosters = posterSeriesList;
            #endregion

            #region Season Posters
            List <string> seasons = new List <string>();
            foreach (XmlNode banner in banners.SelectNodes("/Banners/Banner[BannerType='season']"))
            {
                PosterSeason seasonPoster = new PosterSeason();

                seasonPoster.Language    = banner.SelectSingleNode("Language").InnerText;
                seasonPoster.OnlinePath  = banner.SelectSingleNode("BannerPath").InnerText;
                seasonPoster.SeasonIndex = banner.SelectSingleNode("Season").InnerText;
                seasonPoster.SeriesName  = SeriesName;

                try
                {
                    seasonPoster.Style = (ArtworkStyles)Enum.Parse(typeof(ArtworkStyles), banner.SelectSingleNode("BannerType2").InnerText, true);
                }
                catch
                {
                    // maybe a new style introduced
                    seasonPoster.Style = ArtworkStyles.unknown;
                }

                if (!string.IsNullOrEmpty(banner.SelectSingleNode("Rating").InnerText))
                {
                    double rating = double.Parse(banner.SelectSingleNode("Rating").InnerText, NumberStyles.Any, NumberFormatInfo.InvariantInfo);
                    seasonPoster.Rating = Math.Round(rating, 1, MidpointRounding.AwayFromZero);
                }

                if (!string.IsNullOrEmpty(banner.SelectSingleNode("RatingCount").InnerText))
                {
                    seasonPoster.RatingCount = int.Parse(banner.SelectSingleNode("RatingCount").InnerText);
                }

                if (!seasons.Contains(seasonPoster.SeasonIndex))
                {
                    seasons.Add(seasonPoster.SeasonIndex);
                }

                seasonPoster.SeriesID = seriesID;
                posterSeasonList.Add(seasonPoster);
            }

            posterSeasonList.Sort();

            // we dont support season widebanners
            posterSeasonList.RemoveAll(p => p.Style == ArtworkStyles.seasonwide);

            limit = DBOption.GetOptions(DBOption.cArtworkLimitSeasonPosters);
            List <PosterSeason> posterSeasonListTemp = new List <PosterSeason>(posterSeasonList);

            foreach (string season in seasons)
            {
                int count = 0;
                foreach (PosterSeason pSeason in posterSeasonListTemp)
                {
                    if (season == pSeason.SeasonIndex)
                    {
                        count++;
                        if (limit < count)
                        {
                            posterSeasonList.Remove(pSeason);
                        }
                    }
                }
            }

            map.SeasonPosters = posterSeasonList;
            #endregion

            // series already in?
            if (SeriesBannersMap.Contains(map))
            {
                SeriesBannersMap seriesMap = SeriesBannersMap[SeriesBannersMap.IndexOf(map)];
                seriesMap.SeasonPosters.AddRange(map.SeasonPosters);
                seriesMap.SeriesWideBanners.AddRange(map.SeriesWideBanners);
                seriesMap.SeriesPosters.AddRange(map.SeriesPosters);
            }
            else
            {
                SeriesBannersMap.Add(map);
            }
        }