public bool ReadProgramms(string jspage, DateTime date) { if (string.IsNullOrEmpty(jspage)) { return(false); } if (Source == "web") { return(false); } dynamic dobj = JObject.Parse(jspage); if (dobj.items == null) { return(false); } int ct = 0; foreach (var item in dobj.items) { string chid = item.channel_id; var epg_channel = Channels.Where(d => d.xprs_id == chid).FirstOrDefault(); if (epg_channel == null || !epg_channel.Use) { continue; } var prog = new EpgProgram(); prog.Id = long.Parse((string)item.id); prog.Title = item.title; prog.Description = item.description; prog.Start = item.time_start; prog.End = item.time_stop; if (Dict_EpgProgram.ContainsKey(prog.Id)) { continue; } prog.Channel = epg_channel; epg_channel.temp_list.Add(prog); ct++; } return(ct > 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; } }
public bool ReadProgrammsA(string html_page, DateTime date) { int pos1 = html_page.IndexOf(MyData._str10_prog_list_start); if (pos1 == -1) { return(false); } int pos2 = pos1 + 1; int list_pos_end = html_page.IndexOf(MyData._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(MyData._str11_prog_start, pos2, list_pos_end - pos2); if (pos2 == -1) { return(true); } prog_pos_end = html_page.IndexOf(MyData._str11_prog_end, pos2, list_pos_end - pos2); if (prog_pos_end == -1) { return(false); } pos3 = html_page.IndexOf(MyData._str12_start_time_start, pos2, prog_pos_end - pos2); if (pos3 == -1) { return(false); } pos3 += MyData._str12_start_time_start.Length; prog = new EpgProgram(); prog.Channel = this; s1 = html_page.Substring(pos3, 5); if (!MyData.GetTimeFromStr(s1, out time)) { return(false); } prog.Start = date.Add(time); pos3 = html_page.IndexOf(MyData._str13_title_start, pos2, prog_pos_end - pos2); if (pos3 == -1) { return(false); } pos3 += MyData._str13_title_start.Length; pos4 = html_page.IndexOf(MyData._str13_title_end, pos3, prog_pos_end - pos3); if (pos4 == -1) { return(false); } title_pos_end = pos4 + MyData._str13_title_end.Length; pos3 = html_page.IndexOf(">", pos3, prog_pos_end - pos3); if (pos3 == -1) { return(false); } pos3++; pos3 = html_page.IndexOf(MyData._str12_title2_start, pos2, prog_pos_end - pos2); if (pos3 > -1) { pos3 += MyData._str12_title2_start.Length; pos4 = html_page.IndexOf("\"", pos3, prog_pos_end - pos3); if (pos4 == -1) { return(false); } } pos3 = html_page.IndexOf(MyData._str14_descr_start, title_pos_end, prog_pos_end - title_pos_end); if (pos3 > -1) { pos3 += MyData._str14_descr_start.Length; pos3 = html_page.IndexOf(">", pos3, prog_pos_end - pos3); if (pos3 == -1) { return(false); } pos3++; pos4 = html_page.IndexOf(MyData._str14_descr_end, pos3, prog_pos_end - pos3); if (pos4 == -1) { return(false); } } temp_list.Add(prog); pos2 = prog_pos_end + MyData._str11_prog_end.Length; } }