private List <TVOukokuRecord> Parse_(string html) { List <TVOukokuRecord> ret = new List <TVOukokuRecord>(); html = html.Replace("utileList bl", "utileList"); string[] str = SplitString(html); _D("record list = {0}", str.Length); foreach (string s in str) { TVOukokuRecord rec = new TVOukokuRecord(); try { GetTitle(s, rec); AnalyzeDateTimePlus(s, rec); GetIEPGUrl(s, rec); ret.Add(rec); } catch (NotHaveIEPGException) { /* pass */ } catch (Exception e) { _D("** unexpected format record **\r\n{0}*********************{1}\r\n", e.ToString(), s); } } return(ret); }
private void AnalyzeDateTime(string datatime, TVOukokuRecord target) { _D("<1.1> Enter AnalyzeDateTime()"); Match m = DATATIME_PARSER.Match(datatime); if (!m.Success) { throw new NotFoundException(); } // (?<month>\d)+/(?<day>\d)+\s+\(\s*(?<week>.\)s*\)\s+(?<hour>\d+):(?<minute>\d+)\s+〜\s+\d+:\d+ int month = int.Parse(m.Groups["month"].Value); _D("<1.1> month : {0}", month); int day = int.Parse(m.Groups["day"].Value); _D("<1.1> day : {0}", day); int hour = int.Parse(m.Groups["hour"].Value); _D("<1.1> hour : {0}", hour); int minute = int.Parse(m.Groups["minute"].Value); _D("<1.1> minute : {0}", minute); // 年度越しに対応するのかしら DateTime now = DateTime.Now; int nowYear = now.Year; if (now.Month == 12 && month == 1) { ++nowYear; } DateTime startTime = new DateTime(nowYear, month, day, hour, minute, 0); // success! target.startTime = startTime; _D("<1.1> datetime : {0}", target.startTime.ToString("s")); }
private string GetIEPGFile(TVOukokuRecord rec) { string url = CreateIEPGUrl(rec.iepgURL); _D("iEPGFile url : {0}", url); WebRequest req = CreateWebRequest(url); string iEPGFile = ReadAllString(req, SHIFT_JIS); _D("success to get a iEPGfile."); return(iEPGFile); }
private void GetTitle(string part, TVOukokuRecord target) { _D("<0> Enter GetTitle()"); Match m = TITLE_GETTER.Match(part); if (!m.Success) { throw new NotFoundException(); } target.title = m.Groups[1].Value; _D("<0> get title : {0}", target.title); }
private void AnalyzeTVStation(string station, TVOukokuRecord target) { _D("<1.2> Enter AnalyzeTVStation()"); _D("<1.2> station = {0}", station); station = DELETE_CH.Replace(station, ""); _D("<1.2> station = {0}", station); station = station.ToUpper(); _D("<1.2> station = {0}", station); station = station.Trim(); _D("<1.2> station = {0}", station); station = Strings.StrConv(station, VbStrConv.Wide, 0); _D("<1.2> station = {0}", station); // success!! target.tvStation = station; _D("<1.2> tvStation : {0}", target.tvStation); }
private void GetIEPGUrl(string part, TVOukokuRecord target) { _D("<2> Enter GetIEPGUrl()"); Match m = iEPG_URL.Match(part); if (!m.Success) { throw new NotHaveIEPGException(); } // success! string url = m.Groups[1].Value; target.iepgURL = url; _D("<2> ipegURL = {0}", url); }
private void AnalyzeDateTimePlus(string part, TVOukokuRecord target) { _D("<1> Enter AnalyzeDateTimePlus()"); Match m = DateTimePlus.Match(part); if (!m.Success) { throw new NotFoundException(); } string datatime_plus = m.Groups[0].Value; _D("<1> extract section of dattime and tvStation : {0}", datatime_plus); string[] lines = LINE_SPLITER.Split(datatime_plus); AnalyzeDateTime(lines[1], target); AnalyzeTVStation(lines[2], target); }
public string SearchEntry(ReservationModel reservModel) { _D("enter SearchEntry() : {0}", reservModel.ToString()); string searchRequestURL = createSearchRequestURL(reservModel); _D("searchRequestURL = {0}", searchRequestURL); List <TVOukokuRecord> entryList = GetEntryList(searchRequestURL, reservModel.outputReceiveHTML); _D("entry count = {0}", entryList.Count); string tvStationWide = Strings.StrConv(reservModel.tvStation.ToUpper(), VbStrConv.Wide, 0); _D("entry count = {0}", entryList.Count); TVOukokuRecord matchRec = GetMatchObject(entryList, reservModel.startDateTime, tvStationWide); if (matchRec == null) { throw new TVOukokuException("エントリーが存在しませんでした : \n" + searchRequestURL + "\n"); } string iEPGFile = GetIEPGFile(matchRec); return(iEPGFile); }