Exemplo n.º 1
0
 /// <summary>
 /// Load ntv plus channels
 /// </summary>
 /// <returns></returns>
 public List<ChannelItem> channel_load()
 {
     List<ChannelItem> lch = new List<ItemClass.ChannelItem>();
     string[,] ch;
     string[] cc = new string[] { "Кино", "Спорт", "Познавательное", "HD", "Музыка", "Новости", "Юмор", "Детям", "Эфирные канали", "Другое", "Сериалы", "Эротика" };
     HtmlWeb hwObject = new HtmlWeb();
     HtmlAgilityPack.HtmlDocument htmldocObject = hwObject.Load("http://www.ntvplus.ru/tv/lite.xl");
     int ij = 0;
     //
     foreach (HtmlNode link in htmldocObject.DocumentNode.SelectNodes("//select[@name='channel']/optgroup"))
     {
         string[] str = link.InnerHtml.Split('<');
         foreach (string st in str)
         {
             if (st.Length != 0)
             {
                 string[] ss = st.Split('>');
                 string name = ss[1];
                 string[] s = ss[0].Split('"');
                 string code = s[1];
                 bool isd = true;
                 if (isd)
                 {
                     ItemClass.ChannelItem ci = new ItemClass.ChannelItem();
                     ci.Id = code;
                     ci.Name = name;
                     ci.Category = cc[ij];
                     lch.Add(ci);
                 }
             }
         }
         ij++;
     }
     return lch;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Load channels from file
        /// </summary>
        /// <returns></returns>
        public List<ChannelItem> channel_load()
        {
            List<ChannelItem> lch = new List<ChannelItem>();
            download_xml();

            StreamReader sr = new StreamReader(xmlpath);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sr.ReadToEnd());
            sr.Close();

            foreach (XmlElement xe in doc.DocumentElement.SelectNodes("//channel"))
            {
                ChannelItem ch = new ChannelItem();
                string s = "<root>" + xe.InnerXml + "</root>";
                XmlDocument pdoc = new XmlDocument();
                pdoc.LoadXml(s);

                ch.Id = xe.GetAttribute("id");
                foreach (XmlElement lnks in pdoc.DocumentElement.SelectNodes("//display-name"))
                {
                    ch.Name = lnks.InnerText;
                }
                ch.Category = "ALL";
                lch.Add(ch);
            }
            return lch;
        }