public static void ParseRankingNicoChartOnePage(string html, List <Video> video_list) { int index = 0; while ((index = html.IndexOf("<li id=\"rank", index)) >= 0) { Video video = new Video(); string view_str = IJStringUtil.GetStringBetweenTag(ref index, "em", html); string res_str = IJStringUtil.GetStringBetweenTag(ref index, "em", html); string mylist_str = IJStringUtil.GetStringBetweenTag(ref index, "em", html); video.point.view = IJStringUtil.ToIntFromCommaValue(view_str); video.point.res = IJStringUtil.ToIntFromCommaValue(res_str); video.point.mylist = IJStringUtil.ToIntFromCommaValue(mylist_str); int ps = html.IndexOf("watch/", index) + 6; int pe = html.IndexOf('"', ps); video.video_id = html.Substring(ps, pe - ps); video.title = IJStringUtil.GetStringBetweenTag(ref index, "a", html); index = html.IndexOf("<li class=\"release", index) - 1; string date_str = IJStringUtil.GetStringBetweenTag(ref index, "li", html); video.submit_date = NicoUtil.StringToDate(date_str); if (RankFile.SearchVideo(video_list, video.video_id) < 0) { video_list.Add(video); } } }
public void Parse(string str) { string[] splitter = { "#" }; string[] sArray = str.Split(splitter, StringSplitOptions.RemoveEmptyEntries); getting_date = NicoUtil.StringToDate(sArray[0]); view = int.Parse(sArray[1]); res = int.Parse(sArray[2]); mylist = int.Parse(sArray[3]); }
public void ParseFromIdList(string str) { List <string> id_list = NicoUtil.GetNicoIdList(IJStringUtil.SplitWithCRLF(str)); foreach (string s in id_list) { Video video = new Video(); video.video_id = s; video_list_.Add(video); } }
public string ToStringForPrint() { StringBuilder buff = new StringBuilder(); buff.Append(Filter() ? "○\t" : "×\t"); buff.Append(video_id); buff.Append("\t"); buff.Append(title); buff.Append("\t"); buff.Append(NicoUtil.DateToString(submit_date)); return(buff.ToString()); }
// ランキングまたはマイリストのRSSを解析する // is_mylist が true ならマイリスト、false ならランキング public static void ParsePointRss(string html, DateTime getting_dt, List <Video> video_list, bool is_total, bool is_mylist) { int index = -1; while ((index = html.IndexOf("<item>", index + 1)) >= 0) { Video video = new Video(); video.point.getting_date = getting_dt; video.title = IJStringUtil.GetStringBetweenTag(ref index, "title", html); if (!is_mylist) { video.title = video.title.Substring(video.title.IndexOf(':') + 1); } string link = IJStringUtil.GetStringBetweenTag(ref index, "link", html); video.video_id = link.Substring(link.LastIndexOf('/') + 1); IJStringUtil.GetStringBetweenTag(ref index, "p", html); video.description = IJStringUtil.GetStringBetweenTag(ref index, "p", html); if (!is_mylist) // 読み飛ばし { IJStringUtil.GetStringBetweenTag(ref index, "strong", html); } video.length = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); string date_str = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); video.submit_date = NicoUtil.StringToDate(date_str); if (!is_mylist) { IJStringUtil.GetStringBetweenTag(ref index, "strong", html); if (!is_total) { for (int i = 0; i < 4; ++i) // 4回読み飛ばす { IJStringUtil.GetStringBetweenTag(ref index, "strong", html); } } } string view_str = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); string res_str = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); string mylist_str = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); video.point.view = IJStringUtil.ToIntFromCommaValue(view_str); video.point.res = IJStringUtil.ToIntFromCommaValue(res_str); video.point.mylist = IJStringUtil.ToIntFromCommaValue(mylist_str); if (RankFile.SearchVideo(video_list, video.video_id) < 0) { video_list.Add(video); } } }
public void UpdateMylistDescription(string mylist_id, string text, InputOutputOption iooption) { msgout_.Write("マイリストの説明の更新を開始します。\r\n"); string[] line = IJStringUtil.SplitWithCRLF(iooption.GetRawText()); List <string> add_list = new List <string>(); List <string> description_list = new List <string>(); for (int i = 0; i < line.Length; ++i) { string[] s_array = line[i].Split('\t'); add_list.Add(s_array[0]); description_list.Add(NicoUtil.GetReplacedString(text, s_array).Replace("\\n", "\r\n")); } niconico_network_.UpdateMylistDescription(mylist_id, add_list, description_list, OnUpdateMylistDescriptionEvent); msgout_.Write("マイリストの説明の更新を終了します。\r\n"); }
public string ToStringWithRank(int rank, HoseiKind hosei_kind, int mylist_rate) { if (status_ == Status.DELETED) { return(video_id + "\tDELETED"); } else if (status_ == Status.NOT_FOUND) { return(video_id + "\tDELETED"); } else if (status_ == Status.OTHER) { return(video_id + ""); } else { StringBuilder buff = new StringBuilder(); buff.Append(video_id); buff.Append("\t"); buff.Append(rank.ToString()); buff.Append("\t"); buff.Append(IJStringUtil.ToStringWithComma(point.view)); buff.Append("\t"); buff.Append(IJStringUtil.ToStringWithComma(point.res)); buff.Append("\t"); buff.Append(IJStringUtil.ToStringWithComma(point.mylist)); buff.Append("\t"); buff.Append(point.GetHoseiString(hosei_kind, mylist_rate, 2, hosei_kind == HoseiKind.Nicoran)); buff.Append("\t"); buff.Append(point.GetMylistRateString()); buff.Append("\t"); buff.Append(IJStringUtil.ToStringWithComma(point.CalcScore(hosei_kind, mylist_rate))); buff.Append("\t"); buff.Append(title); buff.Append("\t"); buff.Append(NicoUtil.DateToString(submit_date)); buff.Append("\t"); buff.Append(video_id + ".png"); buff.Append("\t"); buff.Append(pname); buff.Append("\t"); buff.Append(tag_set.ToString()); return(buff.ToString()); } }
public void LoadForSpecial(string rank_file_path) { string str = ""; try { str = IJFile.Read(rank_file_path); } catch (System.IO.FileNotFoundException) { return; } string[] line = IJStringUtil.SplitWithCRLF(str); if (video_list_ == null) { video_list_ = new List <Video>(); } for (int i = 0; i < line.Length; ++i) { string[] s_array = line[i].Split('\t'); if (RankFile.SearchVideo(video_list_, s_array[0]) < 0) // 存在しないなら { Video video = new Video(); video.video_id = s_array[0]; try { video.point.view = IJStringUtil.ToIntFromCommaValue(s_array[3]); video.point.res = IJStringUtil.ToIntFromCommaValue(s_array[4]); video.point.mylist = IJStringUtil.ToIntFromCommaValue(s_array[5]); video.title = s_array[6]; video.submit_date = NicoUtil.StringToDate(s_array[7]); video.tag_set.ParseBlank(s_array[14]); } catch (System.IndexOutOfRangeException) { } video_list_.Add(video); } } }
public void Parse(string str) { string[] line = IJStringUtil.SplitWithCRLF(str); for (int i = 0; i < line.Length; ++i) { if (custom_format_.IsUsingCustomFormat()) { Video video = custom_format_.GetVideo(line[i]); video_list_.Add(video); } else { string[] s_array = line[i].Split('\t'); string[] info = new string[18]; for (int j = 0; j < 18; ++j) { info[j] = (j < s_array.Length) ? s_array[j] : ""; } if (RankFile.SearchVideo(video_list_, info[0]) < 0) // 存在しないなら { Video video = new Video(); video.video_id = info[0]; video.point.view = IJStringUtil.ToIntFromCommaValueWithDef(info[2], 0); video.point.res = IJStringUtil.ToIntFromCommaValueWithDef(info[3], 0); video.point.mylist = IJStringUtil.ToIntFromCommaValueWithDef(info[4], 0); video.title = info[8]; if (info[9] != "") { video.submit_date = NicoUtil.StringToDate(info[9]); } video.pname = info[11]; video.tag_set.Parse(info[12]); video_list_.Add(video); } } } }
// ニコニコ動画IDを抜き出して取得。collection の1つの要素あたり、1つだけ抜き出す。 public static List <string> GetNicoIdList(IEnumerable <string> collection) { List <string> list = new List <string>(); foreach (string s in collection) { string id = NicoUtil.CutNicoVideoId(s); if (id != "") { list.Add(id); } else { Match m = Regex.Match(s, "([0-9]{8,11})"); if (m.Success) { list.Add(m.Groups[1].Value); } } } return(list); }
public void ParseVideo(string str) { string[] splitter1 = { delimiter1_ }; string[] splitter2 = { delimiter2_ }; string[] sArray = str.Split(splitter1, StringSplitOptions.None); video_id = sArray[0]; title = sArray[1]; submit_date = NicoUtil.StringToDate(sArray[2]); string[] rankArray; tag_set.Parse(sArray[3]); rankArray = sArray[4].Split(splitter2, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < rankArray.Length; ++i) { RankPoint point = new RankPoint(); point.Parse(rankArray[i]); val_list_.Add(point); } if (sArray.Length >= 6) { length = sArray[5]; } }
public void PreviewMylistDescription(string text, string rank_file_path) { string[] line = IJStringUtil.SplitWithCRLF(IJFile.Read(rank_file_path)); List <string> add_list = new List <string>(); List <string> description_list = new List <string>(); for (int i = 0; i < line.Length; ++i) { string[] s_array = line[i].Split('\t'); add_list.Add(s_array[0]); description_list.Add(NicoUtil.GetReplacedString(text, s_array)); } StringBuilder buff = new StringBuilder(); for (int i = 0; i < add_list.Count; ++i) { buff.Append(add_list[i]); buff.Append("\r\n---------\r\n"); buff.Append(description_list[i]); buff.Append("\r\n--------------------------------------------------------\r\n"); } msgout_.Write(buff.ToString()); }
public override string ToString() { StringBuilder buff = new StringBuilder(); buff.Append(video_id); buff.Append(delimiter1_); buff.Append(title); buff.Append(delimiter1_); buff.Append(NicoUtil.DateToString(submit_date)); buff.Append(delimiter1_); buff.Append(tag_set.ToString()); buff.Append(delimiter1_); for (int i = 0; i < val_list_.Count; ++i) { buff.Append(val_list_[i].ToString()); if (i < val_list_.Count - 1) { buff.Append(delimiter2_); } } buff.Append(delimiter1_); buff.Append(length); return(buff.ToString()); }
public static void ParseRankingTermPointHtmlVersion1(string html, DateTime getting_dt, List <Video> video_list, string filename) { int index = -1; while ((index = html.IndexOf("<td class=\"rank_num\"", index + 1)) >= 0) { IJStringUtil.GetStringBetweenTag(ref index, "p", html); string valueStr = IJStringUtil.GetStringBetweenTag(ref index, "p", html); IJStringUtil.GetStringBetweenTag(ref index, "strong", html); // 読み飛ばす string dateStr = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); //video.submit_date = IJStringUtil.StringToDate(dateStr); string viewStr = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); if (viewStr.Equals("投稿者コメント")) // 投稿者コメントの部分はとばす { viewStr = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); } string resStr = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); string mylistStr = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); /*point.view = IJStringUtil.GetInt(viewStr); * point.res = IJStringUtil.GetInt(resStr); * point.mylist = IJStringUtil.GetInt(mylistStr);*/ int ps = html.IndexOf("watch/", index) + 6; int pe = html.IndexOf('"', ps); string video_id = html.Substring(ps, pe - ps); string title = IJStringUtil.GetStringBetweenTag(ref index, "a", html); Video video = null; for (int i = 0; i < video_list.Count; ++i) { if (video_list[i].video_id == video_id) { video = video_list[i]; break; } } if (video == null) { video = new Video(); video.point.view = 0; video.point.res = 0; video.point.mylist = 0; video.point.getting_date = getting_dt; video.submit_date = NicoUtil.StringToDate(dateStr); video.video_id = video_id; video.title = title; video_list.Add(video); } if (filename.IndexOf("vie") >= 0) { video.point.view = IJStringUtil.ToIntFromCommaValue(valueStr); } else if (filename.IndexOf("res") >= 0) { video.point.res = IJStringUtil.ToIntFromCommaValue(valueStr); } else if (filename.IndexOf("myl") >= 0) { video.point.mylist = IJStringUtil.ToIntFromCommaValue(valueStr); } else { throw new System.Exception("ファイルの名前の形式が正しくありません"); } } }
public void SetDateTo(string str) { date_to = NicoUtil.StringToDate(str); }
public void SetDateFrom(string str) { date_from = NicoUtil.StringToDate(str); }
public string ToStringForPrint() { return(NicoUtil.DateToString(getting_date) + "\t" + view + "\t" + res + "\t" + mylist); }
public void Substitute(Video video, string str) { switch (kind_) { case Kind.Id: video.video_id = str; break; case Kind.View: video.point.view = IJStringUtil.ToIntFromCommaValue(str); break; case Kind.Res: video.point.res = IJStringUtil.ToIntFromCommaValue(str); break; case Kind.Mylist: video.point.mylist = IJStringUtil.ToIntFromCommaValue(str); break; case Kind.Title: video.title = str; break; case Kind.Date: if (!string.IsNullOrEmpty(str)) { if (text_ != "") // 日時用の書式が存在するなら { video.submit_date = DateTime.ParseExact(str, text_, null); } else { video.submit_date = NicoUtil.StringToDate(str); } } else // 空文字列の場合 { video.submit_date = new DateTime(); } break; case Kind.Description: video.description = str; break; case Kind.Tag: // text_ は separator if (arrange_ == "daily") { video.tag_set.Parse(str); } else { video.tag_set.Parse(str, text_); } break; case Kind.UserText: video.SetUserText(num_, str); break; } }
public string ToStringForSpecial() { return(video_id + "\t" + IJStringUtil.ToStringWithComma(point.view) + "\t" + IJStringUtil.ToStringWithComma(point.res) + "\t" + IJStringUtil.ToStringWithComma(point.mylist) + "\t" + title + "\t" + NicoUtil.DateToString(submit_date) + "\t" + tag_set.ToStringSpace()); }
public void VideoToString(Video video, StringBuilder buff, int line_number) { switch (kind_) { case Kind.Literal: buff.Append(text_); break; case Kind.Id: buff.Append(video.video_id); break; case Kind.View: buff.Append(is_comma_ ? IJStringUtil.ToStringWithComma(video.point.view) : video.point.view.ToString()); break; case Kind.Res: buff.Append(is_comma_ ? IJStringUtil.ToStringWithComma(video.point.res) : video.point.res.ToString()); break; case Kind.Mylist: buff.Append(is_comma_ ? IJStringUtil.ToStringWithComma(video.point.mylist) : video.point.mylist.ToString()); break; case Kind.Title: if (video.GetStatus() == Video.Status.DELETED) { buff.Append("DELETED"); } else { buff.Append(video.title); } break; case Kind.Date: if (text_ != "") // 日時用の書式が存在するなら { buff.Append(video.submit_date.ToString(text_)); } else { buff.Append(NicoUtil.DateToString(video.submit_date)); } break; case Kind.Description: buff.Append(video.description); break; case Kind.LineNumber: // num_ は offset buff.Append((line_number + num_).ToString()); break; case Kind.Tag: // text_ は separator if (arrange_ == "daily") { buff.Append(video.tag_set.GetDisplayingTag()); } else { buff.Append(video.tag_set.ToStringWithSplitter(text_)); } break; case Kind.ExtractTag: if (obj_ != null) { buff.Append(video.tag_set.ExtractTag((Regex)obj_)); } break; case Kind.Expression: buff.Append(DoCalc(text_, video)); break; case Kind.UserText: buff.Append(video.GetUserText(num_)); break; case Kind.Special: break; } }
public override string ToString() { return(NicoUtil.DateToString(getting_date) + "#" + view + "#" + res + "#" + mylist); }