Example #1
0
        public bool ReadChannelsA(string html_page)
        {
            Channels.Clear();
            int pos1 = html_page.IndexOf("<dl id=\"channel-list\">");

            if (pos1 == -1)
            {
                return(false);
            }
            int        pos2 = pos1 + 1;
            int        pos3;
            EpgChannel ch1;

            while (true)
            {
                pos2 = html_page.IndexOf(MyData._str_ch_start, pos2);
                if (pos2 == -1)
                {
                    break;
                }
                pos2 = pos2 + MyData._str_ch_start.Length;

                pos3 = html_page.IndexOf(MyData._str_ch_end, pos2);
                if (pos3 == -1)
                {
                    break;
                }

                ch1 = new EpgChannel();
                var s1 = html_page.Substring(pos2, pos3 - pos2 - MyData._date_length);
                ch1.URL = MyData._str_ch_base_url + s1;

                pos2 = html_page.IndexOf(MyData._str_ch_name_start, pos3);
                if (pos2 == -1)
                {
                    break;
                }

                pos2 += MyData._str_ch_name_start.Length;

                pos3 = html_page.IndexOf(MyData._str_ch_name_end, pos2);
                if (pos3 == -1)
                {
                    break;
                }

                ch1.Name = html_page.Substring(pos2, pos3 - pos2);
                Channels.Add(ch1);

                pos2 = pos3;
            }
            SortChannels();
            Source = "web";
            return(Channels.Count > 0);
        }
Example #2
0
        private void bsChannels_CurrentChanged(object sender, EventArgs e)
        {
            EpgChannel ch = bsChannels.Current as EpgChannel;

            if (ch == null)
            {
                bsPrograms.DataSource = null;
                return;
            }
            bsPrograms.DataSource = ch.Programs;
        }
Example #3
0
        public bool GetCurrentFromFile()
        {
            if (EpgData1.Source == "api")
            {
                return(false);
            }
            DateTime startdate, enddate;

            if (!GetDates(out startdate, out enddate))
            {
                return(false);
            }
            if (EpgData1.Channels.Count == 0)
            {
                return(true);
            }
            if (bsChannels.Current == null)
            {
                return(false);
            }
            task_cur_ch = bsChannels.Current as EpgChannel;
            task_ch_nr  = EpgData1.Channels.IndexOf(task_cur_ch);
            if (task_ch_nr == -1)
            {
                return(false);
            }
            task_date = startdate;

            task_cur_ch.RemoveDates(startdate, enddate);
            EpgData1.ClearTemp();

            string page = File.ReadAllText(tbURL.Text);
            bool   ret  = task_cur_ch.ReadProgrammsA(page, task_date);

            task_cur_ch.AddFromTemp();
            task_cur_ch.CheckEndTimes();

            return(true);
        }
Example #4
0
        public bool ReadChannels(string jspage)
        {
            Channels.Clear();
            if (string.IsNullOrEmpty(jspage))
            {
                return(false);
            }
            dynamic dobj = JObject.Parse(jspage);

            foreach (var item in dobj.items)
            {
                var ch1 = new EpgChannel()
                {
                    Id      = item.id,
                    xprs_id = item.xprs_id,
                    Name    = item.name
                };
                Channels.Add(ch1);
            }
            SortChannels();
            Source = "api";
            return(Channels.Count > 0);
        }
Example #5
0
        private async Task <bool> GetDataA(EpgChannel ch, DateTime date)
        {
            if (EpgData1.Source == "api")
            {
                return(false);
            }
            string url = GetURL(ch, date);

            string page = await ADownloader.GetString(url, LTC.Properties.Settings.Default.HTTPClientTimeOut);

            if (page == null)
            {
                TaskFormMsg(
                    string.Format("Failed to download programs for {0}: {1}",
                                  task_cur_ch.Name, task_date.ToString("yyyy.MM.dd"))
                    );
                return(false);
            }

            //File.WriteAllText(GetBasePath()+"\\e1.html", page);

            bool ret1 = await Task <bool> .Run(() =>
            {
                return(task_cur_ch.ReadProgrammsA(page, task_date));
            });

            if (!ret1)
            {
                TaskFormMsg(
                    string.Format("Failed to read programs for {0}: {1}",
                                  task_cur_ch.Name, task_date.ToString("yyyy.MM.dd"))
                    );
                return(false);
            }

            return(true);
        }
Example #6
0
        public bool ReadChannels(string html_page)
        {
            EpgData1.Channels.Clear();
            int pos1 = html_page.IndexOf("<dl id=\"channel-list\">");
            if (pos1 == -1) return false;
            int pos2 = pos1 + 1;
            int pos3;
            EpgChannel ch1;
            while (true)
            {
                pos2 = html_page.IndexOf(_str_ch_start, pos2);
                if (pos2 == -1) break;
                pos2 = pos2 + _str_ch_start.Length;
                
                pos3 = html_page.IndexOf(_str_ch_end, pos2);
                if (pos3 == -1) break;

                ch1 = new EpgChannel();
                var s1 = html_page.Substring(pos2, pos3 - pos2 - _date_length);
                ch1.URL = _str_ch_base_url + s1;
                
                pos2 = html_page.IndexOf(_str_ch_name_start, pos3);
                if (pos2 == -1) break;
                
                pos2 += _str_ch_name_start.Length;
                
                pos3 = html_page.IndexOf(_str_ch_name_end, pos2);
                if (pos3 == -1) break;

                ch1.Name = html_page.Substring(pos2, pos3 - pos2);
                EpgData1.Channels.Add(ch1);

                pos2 = pos3;
            }
            return EpgData1.Channels.Count > 0;
        }
Example #7
0
        public async Task <bool> GetAllA()
        {
            DateTime startdate, enddate;

            if (!GetDates(out startdate, out enddate))
            {
                return(false);
            }
            if (EpgData1.Channels.Count == 0)
            {
                return(true);
            }
            if (bsChannels.Current == null)
            {
                return(false);
            }
            task_date_start  = startdate;
            task_date_end    = enddate;
            task_date        = startdate;
            task_do_all      = true;
            task_cur_progres = 0.0f;

            CalcProgressIncA();
            OpenTaskForm();
            task_cancel  = false;
            task_started = true;

            EpgData1.RemoveDates(startdate, enddate);
            EpgData1.ClearTemp();

            foreach (var ch in EpgData1.Channels)
            {
                if (!ch.Use)
                {
                    continue;
                }
                task_cur_ch = ch;
                task_date   = task_date_start;
                while (task_date <= task_date_end)
                {
                    if (task_cancel)
                    {
                        break;
                    }

                    bool ret = await GetDataA(task_cur_ch, task_date);

                    await Task.Delay(200);

                    UpdateProgress();
                    if (!ret)
                    {
                        break;
                    }
                    task_date = task_date.AddDays(1);
                }
                if (task_cancel)
                {
                    break;
                }
            }

            EpgData1.AddFromTemp();
            EpgData1.CheckEndTimes();

            Task_done();

            return(true);
        }
Example #8
0
        public async Task <bool> GetCurrentA()
        {
            DateTime startdate, enddate;

            if (!GetDates(out startdate, out enddate))
            {
                return(false);
            }
            if (EpgData1.Channels.Count == 0)
            {
                return(true);
            }
            if (bsChannels.Current == null)
            {
                return(false);
            }
            task_cur_ch = bsChannels.Current as EpgChannel;
            task_ch_nr  = EpgData1.Channels.IndexOf(task_cur_ch);
            if (task_ch_nr == -1)
            {
                return(false);
            }
            task_do_all      = false;
            task_date_start  = startdate;
            task_date_end    = enddate;
            task_date        = startdate;
            task_cur_progres = 0.0f;

            CalcProgressInc();
            OpenTaskForm();
            task_cancel  = false;
            task_started = true;

            task_cur_ch.RemoveDates(startdate, enddate);
            EpgData1.ClearTemp();

            while (task_date <= task_date_end)
            {
                if (task_cancel)
                {
                    break;
                }

                bool ret = await GetDataA(task_cur_ch, task_date);

                await Task.Delay(200);

                UpdateProgress();
                if (!ret)
                {
                    break;
                }
                task_date = task_date.AddDays(1);
            }

            task_cur_ch.AddFromTemp();
            task_cur_ch.CheckEndTimes();

            Task_done();

            return(true);
        }
Example #9
0
 public string GetURL(EpgChannel ch, DateTime date)
 {
     return(string.Format("{0}{1}", ch.URL, date.ToString("dd.MM.yyyy")));
 }
Example #10
0
        private async Task<bool> GetData(EpgChannel ch, DateTime date)
        {
            string url = GetURL(ch, date);

            string page = await ADownloader.GetString(url, LTC.Properties.Settings.Default.HTTPClientTimeOut);

            if (page == null)
            {
                TaskFormMsg(
                    string.Format("Failed to download programs for {0}: {1}",
                        task_cur_ch.Name, task_date.ToString("yyyy.MM.dd"))
                    );
                return false;
            }

            //File.WriteAllText(GetBasePath()+"\\e1.html", page);

            bool ret1 = await Task<bool>.Run(() =>
            {
                return ReadProgramms(page, task_cur_ch, task_date);
            });

            if (!ret1)
            {
                TaskFormMsg(
                    string.Format("Failed to read programs for {0}: {1}",
                        task_cur_ch.Name, task_date.ToString("yyyy.MM.dd"))
                    );
                return false;
            }

            return true;
        }
Example #11
0
        public bool GetCurrentFromFile()
        {
            DateTime startdate, enddate;
            if (!GetDates(out startdate, out enddate)) return false;
            if (EpgData1.Channels.Count == 0) return true;
            if (bsChannels.Current == null) return false;
            task_cur_ch = bsChannels.Current as EpgChannel;
            task_ch_nr = EpgData1.Channels.IndexOf(task_cur_ch);
            if (task_ch_nr == -1) return false;
            task_date = startdate;

            task_cur_ch.RemoveDates(startdate, enddate);
            EpgData1.ClearTemp();

            string page = File.ReadAllText(tbURL.Text);
            bool ret = ReadProgramms(page, task_cur_ch, task_date);

            task_cur_ch.AddFromTemp();
            task_cur_ch.CheckEndTimes();

            return true;
        }
Example #12
0
        public async Task<bool> GetAll()
        {
            DateTime startdate, enddate;
            if (!GetDates(out startdate, out enddate)) return false;
            if (EpgData1.Channels.Count == 0) return true;
            if (bsChannels.Current == null) return false;
            task_date_start = startdate;
            task_date_end = enddate;
            task_date = startdate;
            task_do_all = true;
            task_cur_progres = 0.0f;

            CalcProgressInc();
            OpenTaskForm();
            task_cancel = false;
            task_started = true;

            EpgData1.RemoveDates(startdate, enddate);
            EpgData1.ClearTemp();

            foreach (var ch in EpgData1.Channels)
            {
                if (!ch.Use) continue;
                task_cur_ch = ch;
                task_date = task_date_start;
                while (task_date <= task_date_end)
                {
                    if (task_cancel) break;

                    bool ret = await GetData(task_cur_ch, task_date);

                    await Task.Delay(200);

                    UpdateProgress();
                    if (!ret) break;
                    task_date = task_date.AddDays(1);
                }
                if (task_cancel) break;
            }

            EpgData1.AddFromTemp();
            EpgData1.CheckEndTimes();

            Task_done();

            return true;
        }
Example #13
0
        public async Task<bool> GetCurrent()
        {
            DateTime startdate, enddate;
            if (!GetDates(out startdate, out enddate)) return false;
            if (EpgData1.Channels.Count == 0) return true;
            if (bsChannels.Current == null) return false;
            task_cur_ch = bsChannels.Current as EpgChannel;
            task_ch_nr = EpgData1.Channels.IndexOf(task_cur_ch);
            if (task_ch_nr == -1) return false;
            task_do_all = false;
            task_date_start = startdate;
            task_date_end = enddate;
            task_date = startdate;
            task_cur_progres = 0.0f;
            
            CalcProgressInc();
            OpenTaskForm();
            task_cancel = false;
            task_started = true;

            task_cur_ch.RemoveDates(startdate, enddate);
            EpgData1.ClearTemp();

            while (task_date <= task_date_end)
            {
                if (task_cancel) break;

                bool ret = await GetData(task_cur_ch, task_date);

                await Task.Delay(200);

                UpdateProgress();
                if (!ret) break;
                task_date = task_date.AddDays(1);
            }

            task_cur_ch.AddFromTemp();
            task_cur_ch.CheckEndTimes();
            
            Task_done();

            return true;
        }
Example #14
0
 public string GetURL(EpgChannel ch, DateTime date)
 {
     return string.Format("{0}{1}", ch.URL, date.ToString("dd.MM.yyyy"));
 }
Example #15
0
        public bool ReadProgramms(string html_page, EpgChannel epg_channel, DateTime date)
        {
            int pos1 = html_page.IndexOf(_str10_prog_list_start);
            if (pos1 == -1) return false;
            int pos2 = pos1 + 1;

            int list_pos_end = html_page.IndexOf(_str10_prog_list_end, pos2);
            if (list_pos_end == -1) return false;

            int pos3, pos4;
            int prog_pos_start, prog_pos_end, title_pos_end;
            string s1;
            TimeSpan time;

            EpgProgram prog;

            while (true)
            {
                pos2 = html_page.IndexOf(_str11_prog_start, pos2, list_pos_end - pos2);
                if (pos2 == -1) return true;

                prog_pos_end = html_page.IndexOf(_str11_prog_end, pos2, list_pos_end - pos2);
                if (prog_pos_end == -1) return false;

                pos3 = html_page.IndexOf(_str12_start_time_start, pos2, prog_pos_end - pos2);
                if (pos3 == -1) return false;
                pos3 += _str12_start_time_start.Length;

                prog = new EpgProgram();
                prog.Channel = epg_channel;

                s1 = html_page.Substring(pos3, 5);
                if (!GetTimeFromStr(s1, out time)) return false;
                prog.Start = date.Add(time);

                pos3 = html_page.IndexOf(_str13_title_start, pos2, prog_pos_end - pos2);
                if (pos3 == -1) return false;
                pos3 += _str13_title_start.Length;
                pos4 = html_page.IndexOf(_str13_title_end, pos3, prog_pos_end - pos3);
                if (pos4 == -1) return false;
                title_pos_end = pos4 + _str13_title_end.Length;
                pos3 = html_page.IndexOf(">", pos3, prog_pos_end - pos3);
                if (pos3 == -1) return false;
                pos3++;
                prog.Title = Utils.UnescapeXMLText(html_page.Substring(pos3, pos4 - pos3));

                pos3 = html_page.IndexOf(_str12_title2_start, pos2, prog_pos_end - pos2);
                if (pos3 > -1)
                {
                    pos3 += _str12_title2_start.Length;
                    pos4 = html_page.IndexOf("\"", pos3, prog_pos_end - pos3);
                    if (pos4 == -1) return false;
                    prog.Title = Utils.UnescapeXMLText(html_page.Substring(pos3, pos4 - pos3));
                }

                pos3 = html_page.IndexOf(_str14_descr_start, title_pos_end, prog_pos_end - title_pos_end);
                if (pos3 > -1)
                {
                    pos3 += _str14_descr_start.Length;
                    pos3 = html_page.IndexOf(">", pos3, prog_pos_end - pos3);
                    if (pos3 == -1) return false;
                    pos3++;
                    pos4 = html_page.IndexOf(_str14_descr_end, pos3, prog_pos_end - pos3);
                    if (pos4 == -1) return false;
                    prog.Description = Utils.UnescapeXMLText(html_page.Substring(pos3, pos4 - pos3));
                }

                epg_channel.temp_list.Add(prog);
                pos2 = prog_pos_end + _str11_prog_end.Length;
            }
        }