Пример #1
0
        private void ReadChannel(string line)
        {
            var parts = CsvFile.Parse(line, ',');

            if (parts.Count < 5)
            {
                return;
            }
            int programNr;

            if (!int.TryParse(parts[1], out programNr))
            {
                return;
            }
            string uid = parts[3];

            if (uid.StartsWith("S")) // remove satellite orbital position from UID ... not all TV models provide this information
            {
                uid = "S" + uid.Substring(uid.IndexOf('-'));
            }
            SignalSource signalSource = GetSignalSource(ref programNr, uid, parts);

            if (signalSource == 0)
            {
                return;
            }

            string      name        = parts[4];
            ChannelList channelList = this.GetInitiallyClearedChannelList(signalSource);

            if (channelList == null)
            {
                return;
            }

            IEnumerable <ChannelInfo> channels = FindChannels(channelList, name, uid);
            var channel = channels == null ? null : channels.FirstOrDefault(c => c.NewProgramNr == -1);

            if (channel != null)
            {
                if (!this.addChannels)
                {
                    channel.NewProgramNr = programNr;
                    if ((channel.SignalSource & SignalSource.Analog) != 0)
                    {
                        channel.Name           = name;
                        channel.IsNameModified = true;
                    }
                    if (parts.Count >= 7)
                    {
                        ApplyFlags(channel, parts[6]);
                    }
                }
            }
            else if (parts.Count >= 6) // create proxy channel when using the new ref-list format
            {
                channel = new ChannelInfo(signalSource, uid, programNr, name);
                if (addChannels)
                {
                    channel.NewProgramNr = -1;
                    channel.OldProgramNr = programNr;
                }
                channelList.AddChannel(channel);
            }
        }
Пример #2
0
        private void ReadChannel(string line, int lineNr)
        {
            var parts = CsvFile.Parse(line, ',');

            if (parts.Count < 5)
            {
                return;
            }
            int programNr;

            if (!int.TryParse(parts[1], out programNr))
            {
                return;
            }
            var uid = parts[3];

            if (uid.StartsWith("S")) // remove satellite orbital position from UID ... not all TV models provide this information
            {
                uid = "S" + uid.Substring(uid.IndexOf('-'));
            }
            var signalSource = GetSignalSource(ref programNr, uid, parts);

            if (signalSource == 0)
            {
                return;
            }

            var channelList = this.GetChannelList(signalSource);

            if (channelList == null)
            {
                return;
            }

            var name    = parts[4];
            var channel = new ChannelInfo(signalSource, lineNr, programNr, name);

            var uidParts = uid.Split('-');

            if (uidParts.Length >= 4)
            {
                int val;
                if (int.TryParse(uidParts[1], out val))
                {
                    channel.OriginalNetworkId = val;
                }
                if (int.TryParse(uidParts[2], out val))
                {
                    channel.TransportStreamId = val;
                }
                if (int.TryParse(uidParts[3], out val))
                {
                    channel.ServiceId = val;
                }
            }

            if (parts.Count >= 7)
            {
                ApplyFlags(channel, parts[6]);
            }

            this.DataRoot.AddChannel(channelList, channel);
        }