コード例 #1
0
ファイル: seriesImages.cs プロジェクト: garyan2/epg123
        private static MxfGuideImage GetGuideImageAndUpdateCache(List <ProgramArtwork> artwork, ImageType type, string cacheKey = null)
        {
            if (artwork.Count == 0)
            {
                if (cacheKey != null)
                {
                    epgCache.UpdateAssetImages(cacheKey, string.Empty);
                }
                return(null);
            }
            if (cacheKey != null)
            {
                using (var writer = new StringWriter())
                {
                    var serializer = new JsonSerializer();
                    serializer.Serialize(writer, artwork);
                    epgCache.UpdateAssetImages(cacheKey, writer.ToString());
                }
            }

            ProgramArtwork image = null;

            if (type == ImageType.Movie)
            {
                image = artwork.FirstOrDefault();
            }
            else if (config.SeriesPosterArt || config.SeriesWsArt)
            {
                image = artwork.SingleOrDefault(arg =>
                                                arg.Aspect.ToLower().Equals(config.SeriesPosterArt ? "2x3" : "16x9"));
            }
            else
            {
                image = artwork.SingleOrDefault(arg => arg.Aspect.ToLower().Equals("4x3"));
            }

            if (image == null && type == ImageType.Series)
            {
                image = artwork.SingleOrDefault(arg => arg.Aspect.ToLower().Equals("4x3"));
            }
            return(image != null?SdMxf.GetGuideImage(Helper.Standalone?image.Uri : image.Uri.Replace($"{SdApi.JsonBaseUrl}{SdApi.JsonApi}", $"http://{Environment.MachineName}:{Helper.TcpPort}/")) : null);
        }
コード例 #2
0
ファイル: seriesImages.cs プロジェクト: garyan2/epg123
        private static List <ProgramArtwork> GetTieredImages(List <ProgramArtwork> sdImages, List <string> tiers)
        {
            var ret    = new List <ProgramArtwork>();
            var images = sdImages.Where(arg =>
                                        !string.IsNullOrEmpty(arg.Category) && !string.IsNullOrEmpty(arg.Aspect) &&
                                        !string.IsNullOrEmpty(arg.Uri) &&
                                        (string.IsNullOrEmpty(arg.Tier) || tiers.Contains(arg.Tier.ToLower())) &&
                                        !string.IsNullOrEmpty(arg.Size) && (arg.Size.Equals("Md") && !arg.Aspect.Equals("16x9") && !arg.Aspect.Equals("1x1") ||
                                                                            arg.Size.Equals("Sm") && arg.Aspect.Equals("16x9")));

            // get the aspect ratios available and fix the URI
            var aspects = new HashSet <string>();

            foreach (var image in images)
            {
                aspects.Add(image.Aspect);
                if (!image.Uri.ToLower().StartsWith("http"))
                {
                    image.Uri = $"{SdApi.JsonBaseUrl}{SdApi.JsonApi}image/{image.Uri.ToLower()}";
                }
            }

            // determine which image to return with each aspect
            foreach (var aspect in aspects)
            {
                var imgAspects = images.Where(arg => arg.Aspect.Equals(aspect));

                var links = new ProgramArtwork[11];
                foreach (var image in imgAspects)
                {
                    switch (image.Category.ToLower())
                    {
                    case "box art":         // DVD box art, for movies only
                        if (links[0] == null)
                        {
                            links[0] = image;
                        }
                        break;

                    case "vod art":
                        if (links[1] == null)
                        {
                            links[1] = image;
                        }
                        break;

                    case "poster art":      // theatrical movie poster, standard sizes
                        if (links[2] == null)
                        {
                            links[2] = image;
                        }
                        break;

                    case "banner":          // source-provided image, usually shows cast ensemble with source-provided text
                        if (links[3] == null)
                        {
                            links[3] = image;
                        }
                        break;

                    case "banner-l1":       // same as Banner
                        if (links[4] == null)
                        {
                            links[4] = image;
                        }
                        break;

                    case "banner-l2":       // source-provided image with plain text
                        if (links[5] == null)
                        {
                            links[5] = image;
                        }
                        break;

                    case "banner-lo":       // banner with Logo Only
                        if (links[6] == null)
                        {
                            links[6] = image;
                        }
                        break;

                    case "logo":            // official logo for program, sports organization, sports conference, or TV station
                        if (links[7] == null)
                        {
                            links[7] = image;
                        }
                        break;

                    case "banner-l3":       // stock photo image with plain text
                        if (links[8] == null)
                        {
                            links[8] = image;
                        }
                        break;

                    case "iconic":          // representative series/season/episode image, no text
                        if (tiers.Contains("series") && links[9] == null)
                        {
                            links[9] = image;
                        }
                        break;

                    case "staple":          // the staple image is intended to cover programs which do not have a unique banner image
                        if (links[10] == null)
                        {
                            links[10] = image;
                        }
                        break;

                    case "banner-l1t":
                    case "banner-lot":      // banner with Logo Only + Text indicating season number
                        break;
                    }
                }

                foreach (var link in links)
                {
                    if (link == null)
                    {
                        continue;
                    }
                    ret.Add(link);
                    break;
                }
            }

            if (ret.Count > 1)
            {
                ret = ret.OrderBy(arg => arg.Width).ToList();
            }
            return(ret);
        }