Ejemplo n.º 1
0
        public static XmltvChannel BuildXmltvChannel(MxfService mxfService)
        {
            // initialize the return channel
            var ret = new XmltvChannel
            {
                Id           = $"EPG123.{mxfService.StationId}.schedulesdirect.org",
                DisplayNames = new List <XmltvText>()
            };

            // minimum display names
            // 5MAXHD
            // 5 StarMAX HD East
            ret.DisplayNames.Add(new XmltvText {
                Text = mxfService.CallSign
            });
            if (!mxfService.Name.Equals(mxfService.CallSign))
            {
                ret.DisplayNames.Add(new XmltvText {
                    Text = mxfService.Name
                });
            }

            // add channel number if requested
            if (config.XmltvIncludeChannelNumbers)
            {
                var numbers = new HashSet <string>();
                foreach (var mxfLineup in SdMxf.With.Lineups)
                {
                    foreach (var mxfChannel in mxfLineup.channels)
                    {
                        if (mxfChannel.Service != mxfService.Id || mxfChannel.Number <= 0)
                        {
                            continue;
                        }

                        var num = $"{mxfChannel.Number}" + (mxfChannel.SubNumber > 0 ? $".{mxfChannel.SubNumber}" : "");
                        if (!numbers.Add(num))
                        {
                            continue;
                        }

                        ret.DisplayNames.Add(new XmltvText {
                            Text = num + " " + mxfService.CallSign
                        });
                        ret.DisplayNames.Add(new XmltvText {
                            Text = num
                        });
                    }
                }
            }

            // add affiliate if present
            var affiliate = mxfService.mxfAffiliate?.Name;

            if (!string.IsNullOrEmpty(affiliate) && !mxfService.Name.Equals(affiliate))
            {
                ret.DisplayNames.Add(new XmltvText {
                    Text = affiliate
                });
            }

            // add logo if available
            if (mxfService.extras.ContainsKey("logo"))
            {
                ret.Icons = new List <XmltvIcon>
                {
                    new XmltvIcon
                    {
                        Src    = mxfService.extras["logo"].Url,
                        Height = mxfService.extras["logo"].Height,
                        Width  = mxfService.extras["logo"].Width
                    }
                };
            }
            return(ret);
        }
Ejemplo n.º 2
0
        public static XmltvChannel buildXmltvChannel(MxfChannel mxfChannel)
        {
            // determine what service this channel belongs to
            MxfService mxfService = sdMxf.With[0].Services.Where(arg => arg.Id.Equals(mxfChannel.Service)).Single();

            // initialize the return channel
            XmltvChannel ret = new XmltvChannel()
            {
                Id           = mxfService.xmltvChannelID,
                DisplayNames = new List <XmltvText>()
            };

            // minimum display names
            // 5MAXHD
            // 5 StarMAX HD East
            ret.DisplayNames.Add(new XmltvText()
            {
                Text = mxfService.CallSign
            });
            if (!mxfService.Name.Equals(mxfService.CallSign))
            {
                ret.DisplayNames.Add(new XmltvText()
                {
                    Text = mxfService.Name
                });
            }

            // add channel number if requested
            if (config.XmltvIncludeChannelNumbers)
            {
                if (mxfChannel.Number > 0)
                {
                    string num = mxfChannel.Number.ToString();
                    num += (mxfChannel.SubNumber > 0) ? "." + mxfChannel.SubNumber.ToString() : string.Empty;

                    ret.DisplayNames.Add(new XmltvText()
                    {
                        Text = num + " " + mxfService.CallSign
                    });
                    ret.DisplayNames.Add(new XmltvText()
                    {
                        Text = num
                    });
                }
            }

            // add affiliate if present
            if (!string.IsNullOrEmpty(mxfService.Affiliate))
            {
                ret.DisplayNames.Add(new XmltvText()
                {
                    Text = mxfService.Affiliate.Substring(11)
                });
            }

            // add logo if available
            if (mxfService.logoImage != null)
            {
                ret.Icons = new List <XmltvIcon>()
                {
                    new XmltvIcon()
                    {
                        src    = mxfService.logoImage.URL,
                        height = mxfService.logoImage.Height.ToString(),
                        width  = mxfService.logoImage.Width.ToString()
                    }
                };
            }
            return(ret);
        }