public void ParseCategoryFile() { string filename = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "category.txt"); string str; if (File.Exists(filename)) { str = IJFile.ReadUTF8(filename); } else { throw new FileNotFoundException("category.txt が存在しません。nicorank.exe を起動して category.txt を作成してください。"); } string[] lines = IJStringUtil.SplitWithCRLF(str); for (int i = 1; i < lines.Length; ++i) { string[] ar = lines[i].Split('\t'); CategoryItem item = new CategoryItem(); item.id = ar[0]; item.short_name = ar[1]; item.name = ar[2]; int[] page = new int[5]; for (int j = 0; j < page.Length; ++j) { page[j] = int.Parse(ar[3 + j]); } item.page = page; category_item_dic_.Add(item.name, item); } }
// 古いので消す public List <string> GetIdListFromTextBox() { string[] s_array = IJStringUtil.SplitWithCRLF(textBoxInputRank.Text); List <string> list = new List <string>(); for (int i = 0; i < s_array.Length; ++i) { int start = s_array[i].IndexOf("sm"); if (start < 0) { start = s_array[i].IndexOf("nm"); } if (start < 0) { continue; } int end = start + 2; while (end < s_array[i].Length && s_array[i][end] >= '0' && s_array[i][end] <= '9') { ++end; } list.Add(s_array[i].Substring(start, end - start)); } return(list); }
public string CategorizePname(string plist, out string kekka) { string[] pname_array = IJStringUtil.SplitWithCRLF(plist); StringBuilder buff = new StringBuilder(); StringBuilder buff_kekka = new StringBuilder(); for (int i = 0; i < pname_array.Length; i += 3) { StringBuilder buff_pname = new StringBuilder(); int view = 0; int res = 0; int mylist = 0; for (int j = 0; j < video_list_.Count; ++j) { if (video_list_[j].tag_set.IsInclude(pname_array[i + 1]) || video_list_[j].tag_set.IsInclude(pname_array[i + 2])) { buff_pname.Append("\t"); buff_pname.Append(video_list_[j].ToStringForSpecial()); buff_pname.Append("\r\n"); view += video_list_[j].point.view; res += video_list_[j].point.res; mylist += video_list_[j].point.mylist; } } string s = (i / 3 + 1).ToString() + "\t" + pname_array[i + 1] + "\t" + pname_array[i + 2] + "\t" + view.ToString() + "\t" + res.ToString() + "\t" + mylist.ToString() + "\r\n"; buff.Append(s); buff_kekka.Append(s); buff.Append(buff_pname); } kekka = buff_kekka.ToString(); return(buff.ToString()); }
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 void SetRankFile(string rank_file_str) { string[] rank_file_lines = new string[0]; if (rank_file_str != "") { rank_file_lines = IJStringUtil.SplitWithCRLF(rank_file_str); } Register("end", rank_file_lines.Length); matrix_ = new string[rank_file_lines.Length][]; for (int i = 0; i < matrix_.Length; ++i) { matrix_[i] = rank_file_lines[i].Split('\t'); } }
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"); }
static void ParseConfig(string text) { string[] lines = IJStringUtil.SplitWithCRLF(text); for (int i = 0; i < lines.Length; ++i) { string[] ar = lines[i].Split('\t'); if (ar[0] != "version") { if (ar.Length >= 3) { option_[ar[1]] = ar[2]; } else { option_[ar[0]] = ar[1]; } } } }
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); } } } }
// タグリストから P名を推定する public static string GetPname(TagSet tag_set, out int index) { if (pname_list_ == null) // 初回にリストをロードする { if (File.Exists("pnamelist.txt")) { pname_list_ = IJStringUtil.SplitWithCRLF(IJFile.Read("pnamelist.txt")); } else { pname_list_ = new string[0]; } } for (int i = 0; i < tag_set.tag_list_.Count; ++i) { for (int j = 0; j < pname_list_.Length; ++j) { if (IJStringUtil.CompareString(tag_set.tag_list_[i].GetRawTag(), pname_list_[j])) { index = i; return(pname_list_[j]); } } } // リストから見つからない場合は後ろにPのついたタグを探す for (int i = 0; i < tag_set.tag_list_.Count; ++i) { if (tag_set.tag_list_[i].GetRawTag().EndsWith("P", StringComparison.InvariantCultureIgnoreCase) || tag_set.tag_list_[i].GetRawTag().EndsWith("P", StringComparison.InvariantCultureIgnoreCase)) { index = i; return(tag_set.tag_list_[i].GetRawTag()); } } index = -1; return(""); // それでも見つからないときは空文字を返す }
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 void ParseCategoryFile2(Form form) { string filename = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "category.txt"); string str; if (File.Exists(filename)) { str = IJFile.ReadUTF8(filename); if (!str.StartsWith("version")) // 昔のバージョンの category.txt なら { if (str != Properties.Resources.category204) // ユーザによって改変されているなら { File.Move(filename, Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "category_old1.txt")); // 念のためバックアップを取る if (form != null) { MessageBox.Show(form, "category.txt を category_old1.txt にリネームしました。", "ニコニコランキングメーカー", MessageBoxButtons.OK, MessageBoxIcon.Information); } else // for console { System.Console.WriteLine("category.txt を category_old1.txt にリネームしました。"); } } else { File.Delete(filename); } str = Properties.Resources.category; IJFile.WriteUTF8(filename, str); } } else { str = Properties.Resources.category; IJFile.WriteUTF8(filename, str); } string[] lines = IJStringUtil.SplitWithCRLF(str); for (int i = 1; i < lines.Length; ++i) { string[] ar = lines[i].Split('\t'); CategoryItem item = new CategoryItem(); item.id = ar[0]; item.short_name = ar[1]; item.name = ar[2]; int[] page = new int[5]; for (int j = 0; j < page.Length; ++j) { page[j] = int.Parse(ar[3 + j]); } item.page = page; category_item_dic_.Add(item.name, item); clistbox_.Items.Add(item.name, Array.IndexOf(category_config_, item.id) >= 0); } }
public void SetTagList(string str) { searching_tag_list = new List <string>(IJStringUtil.SplitWithCRLF(str)); ticket_id = null; }