Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        static SearchingTagOption MakeSearchingTagOption()
        {
            SearchingTagOption searching_tag_option = new SearchingTagOption();

            searching_tag_option.SetTagList(option_["textBoxTagNew"]);
            searching_tag_option.is_searching_kind_tag = bool.Parse(option_["radioButtonSearchKindTag"]);
            searching_tag_option.is_detail_getting     = bool.Parse(option_["checkBoxIsGettingDetailNew"]);
            searching_tag_option.detail_info_lower     = int.Parse(option_["numericUpDownConditionMylistNew"]);
            searching_tag_option.sort_kind_num         = int.Parse(option_["listBoxSortNew"]);
            searching_tag_option.is_page_all           = bool.Parse(option_["radioButtonTagSearchPageAll"]);
            searching_tag_option.page_start            = IJStringUtil.ToNumberWithDef(option_["textBoxTagSearchPageStart"], 1);
            searching_tag_option.page_end                = IJStringUtil.ToNumberWithDef(option_["textBoxTagSearchPageEnd"], int.MaxValue);
            searching_tag_option.is_using_condition      = bool.Parse(option_["checkBoxTagSearchIsUsingCondition"]);
            searching_tag_option.condition_lower         = IJStringUtil.ToNumberWithDef(option_["textBoxTagSearchLower"], 0);
            searching_tag_option.condition_upper         = IJStringUtil.ToNumberWithDef(option_["textBoxTagSearchUpper"], int.MaxValue);
            searching_tag_option.date_from               = NicoUtil.StringToDate(option_["dateTimePickerTagSearchFrom"]);
            searching_tag_option.date_to                 = NicoUtil.StringToDate(option_["dateTimePickerTagSearchTo"]);
            searching_tag_option.searching_interval      = option_["textBoxTagSearchInterval"];
            searching_tag_option.getting_detail_interval = option_["textBoxGettingDetailInterval"];
            searching_tag_option.is_create_ticket        = bool.Parse(option_["checkBoxSaveSearch"]);
            searching_tag_option.SetRedundantSearchMethod(int.Parse(option_["comboBoxRedundantSearchMethod"]));
            searching_tag_option.is_sending_user_session = bool.Parse(option_["checkBoxIsSendingUserSession"]);

            return(searching_tag_option);
        }
Пример #4
0
        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());
        }
Пример #5
0
        public static List <Video> ParseMyVideoHtml(string html)
        {
            if (html.IndexOf("ここから先をご利用いただくにはログインしてください") >= 0)
            {
                throw new NiconicoLoginException();
            }

            List <Video> video_list = new List <Video>();

            // 動画が1つもない場合の処理が必要

            int index = 0;

            while ((index = html.IndexOf("<p class=\"menu_box\">", index)) >= 0)
            {
                Video  video    = new Video();
                string date_str = IJStringUtil.GetStringBetweenTag(ref index, "strong", html);
                video.submit_date = DateTime.ParseExact(date_str, "yy年MM月dd日 HH:mm", null);

                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);
                int start = html.IndexOf("watch/", index) + "watch/".Length;
                int end   = html.IndexOf('"', start);
                video.video_id    = html.Substring(start, end - start);
                video.title       = IJStringUtil.GetStringBetweenTag(ref index, "a", html);
                video.description = IJStringUtil.GetStringBetweenTag(ref index, "p", html); // description の欄を仮に使う
                video_list.Add(video);
            }
            return(video_list);
        }
Пример #6
0
        private bool CheckTagSearchInterval()
        {
            if (textBoxTagSearchInterval.Text == "")
            {
                textBoxTagSearchInterval.Text = "8";
            }
            double interval_min = 8.0;
            double interval_max = 10.0;

            try
            {
                IJStringUtil.ParseDlInterval(textBoxTagSearchInterval.Text, ref interval_min, ref interval_max);
            }
            catch (FormatException)
            {
                textBoxInfo.AppendText("タグ検索の間隔の指定が正しくありません。\r\n");
                return(false);
            }
            if (interval_min < 3.0)
            {
                textBoxInfo.AppendText("タグ検索の間隔は3秒未満にはできません。\r\n");
                return(false);
            }
            return(true);
        }
Пример #7
0
        private void MakeUserFile()
        {
            string str = IJStringUtil.EncryptString(textBoxUser.Text, "dailyvocaran") + "\t" +
                         IJStringUtil.EncryptString(textBoxPassword.Text, "dailyvocaran");

            IJFile.Write(userdat_filename, str);
        }
Пример #8
0
        // 古いので消す
        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);
        }
Пример #9
0
        private bool CheckGettingDetailInterval()
        {
            if (textBoxGettingDetailInterval.Text == "")
            {
                textBoxGettingDetailInterval.Text = "0.5";
            }
            double interval_min = 0.3;
            double interval_max = 0.5;

            try
            {
                IJStringUtil.ParseDlInterval(textBoxGettingDetailInterval.Text, ref interval_min, ref interval_max);
            }
            catch (FormatException)
            {
                textBoxInfo.AppendText("詳細情報取得の間隔の指定が正しくありません。\r\n");
                return(false);
            }
            if (interval_min < 0.1)
            {
                textBoxInfo.AppendText("詳細情報取得の間隔は0.1秒未満にはできません。\r\n");
                return(false);
            }
            return(true);
        }
Пример #10
0
        // タグ編集を開始するときに得られるHTMLを解析する
        public void ParseEditHtml(string html)
        {
            int          index;
            int          next         = 0;
            const string lock_str     = "<span style=\"color:#F90;\">★</span>";
            const string category_str = " <strong style=\"color:#F30;\">カテゴリ</strong>";

            while ((next = html.IndexOf("<td id=\"tag_edit_status", next)) >= 0)
            {
                index = html.LastIndexOf("<td>", next);
                string tag     = IJStringUtil.GetStringBetweenTag(ref index, "td", html);
                bool   is_lock = (tag.IndexOf(lock_str) >= 0);
                tag = tag.Replace(lock_str, "").Replace(category_str, "");
                if (tag.EndsWith(" "))
                {
                    tag = tag.Remove(tag.Length - 1);
                }
                index = html.IndexOf("name=\"id\"", index);
                index = html.IndexOf("value", index);
                index = html.IndexOf('"', index) + 1;
                int    end = html.IndexOf('"', index);
                string id  = html.Substring(index, end - index);
                tag_list_.Add(new TagElement(tag, is_lock, id));
                ++next;
            }
        }
Пример #11
0
        /// <summary>
        /// #記法を置き換える。
        /// "#m:n" を element[m - 1][n - 1] で置き換えたテキストを取得
        /// </summary>
        /// <param name="text">置換元文字列</param>
        /// <param name="element">置換するデータ</param>
        /// <returns>置き換えられた文字列</returns>
        public static string GetReplacedString(string text, List <string[]> element)
        {
            StringBuilder buff = new StringBuilder();

            for (int i = 0; i < text.Length; ++i)
            {
                if (text[i] == '#' && i < text.Length - 1 && text[i + 1] == '#')
                {
                    buff.Append((char)'#');
                    ++i;
                }
                else if (text[i] == '#')
                {
                    int    row           = 0;
                    int    column        = 0;
                    string format_string = "";
                    ParseSharp(text, ref i, ref row, ref column, ref format_string);
                    if (row >= 0) // -1 なら普通のテキストと解釈
                    {
                        while (row - 1 < element.Count && column - 1 >= element[row - 1].Length)
                        {
                            column -= element[row - 1].Length;
                            ++row;
                        }
                        string value = ((row - 1 < element.Count && column - 1 < element[row - 1].Length) ? element[row - 1][column - 1] : "");
                        if (value != "")
                        {
                            if (format_string != "")
                            {
                                format_string = "{0," + format_string + "}";
                                if (value.IndexOf('.') >= 0)
                                {
                                    buff.Append(String.Format(format_string, double.Parse(value)));
                                }
                                else
                                {
                                    buff.Append(String.Format(format_string, IJStringUtil.ToIntFromCommaValue(value)));
                                }
                            }
                            else
                            {
                                buff.Append(value);
                            }
                        }
                    }
                    else
                    {
                        buff.Append((char)text[i]);
                    }
                }
                else
                {
                    buff.Append((char)text[i]);
                }
            }
            return(buff.ToString());
        }
Пример #12
0
 public void DeleteTag(string tag)
 {
     for (int i = tag_list_.Count - 1; i >= 0; --i)
     {
         if (IJStringUtil.CompareString(tag_list_[i].GetRawTag(), tag))
         {
             tag_list_.RemoveAt(i);
         }
     }
 }
Пример #13
0
        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);
            }
        }
Пример #14
0
 public bool IsIncludeAndLocked(string tag)
 {
     for (int i = 0; i < tag_list_.Count; ++i)
     {
         if (IJStringUtil.CompareString(tag, tag_list_[i].GetRawTag()) && tag_list_[i].IsLock())
         {
             return(true);
         }
     }
     return(false);
 }
Пример #15
0
 private static bool IsExclusion(string str, string[] exclusion_tag)
 {
     for (int i = 0; i < exclusion_tag.Length; ++i)
     {
         if (IJStringUtil.CompareString(str, exclusion_tag[i]))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #16
0
 public override bool IsThrough(Video video)
 {
     for (int i = 0; i < word_list_.Count; ++i)
     {
         if (IJStringUtil.IndexOfIgnoreCase(video.title, word_list_[i]) >= 0)
         {
             return(is_affirmation_);
         }
     }
     return(!is_affirmation_);
 }
Пример #17
0
 public void PreParse(string str)
 {
     if (str == "")
     {
         return;
     }
     string[] line = IJStringUtil.SplitWithCRLFAndEraseComment(str);
     ParseLine(line[0]);
     for (int i = 1; i < line.Length; ++i)
     {
         element_list_.Add(new CustomFormatElement(line[i]));
     }
 }
Пример #18
0
        // ランキングまたはマイリストの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);
                }
            }
        }
Пример #19
0
 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');
     }
 }
Пример #20
0
        public IFilterManager GetFilter()
        {
            IFilterManager filter;

            if (is_using_filter && filter_filename != "" && File.Exists(filter_filename))
            {
                try
                {
                    string first_line = IJFile.ReadFirstLineUTF8(filter_filename);

                    // フィルター書式のバージョンを調べる(ファイルの最初の行が「version=2」であるかどうか)
                    bool is_version2 = IJStringUtil.CompareString(first_line, RootFilter.version_indicator);

                    string str;

                    if (is_version2)
                    {
                        // 新フィルターはUTF-8で読み込む
                        string str_with_version = IJFile.ReadUTF8(filter_filename);

                        // 先頭の「version=2」を削除する
                        int start_index = str_with_version.IndexOfAny(new char[] { '\r', '\n' }, 0);
                        if (start_index + 1 <= str_with_version.Length - 1)
                        {
                            str = str_with_version.Substring(start_index + 1);
                        }
                        else
                        {
                            str = string.Empty;
                        }

                        filter = GetFilter2(str);
                    }
                    else
                    {
                        str    = IJFile.Read(filter_filename);
                        filter = GetFilter1(str);
                    }
                }
                catch (Exception)
                {
                    throw new FormatException("フィルターの書式が間違えています。");
                }
                return(filter);
            }
            return(new Filter(is_output_filtered_video));
        }
Пример #21
0
        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");
        }
Пример #22
0
 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());
     }
 }
Пример #23
0
        public void ParseExtThumb(string html)
        {
            int index;

            if ((index = html.IndexOf("<p class=\"TXT10")) >= 0)
            {
                point.view   = IJStringUtil.ToIntFromCommaValue(IJStringUtil.GetStringBetweenTag(ref index, "strong", html));
                point.res    = IJStringUtil.ToIntFromCommaValue(IJStringUtil.GetStringBetweenTag(ref index, "strong", html));
                point.mylist = IJStringUtil.ToIntFromCommaValue(IJStringUtil.GetStringBetweenTag(ref index, "strong", html));
                length       = IJStringUtil.GetStringBetweenTag(ref index, "strong", html);
                submit_date  = DateTime.ParseExact(IJStringUtil.GetStringBetweenTag(ref index, "strong", html), "yy/MM/dd HH:mm", null);
                title        = IJStringUtil.GetStringBetweenTag(ref index, "a", html);
            }
            else
            {
                status_ = Status.OTHER;
            }
        }
Пример #24
0
 public void Add(TagSet tag_set)
 {
     for (int i = 0; i < tag_set.tag_list_.Count; ++i)
     {
         int j;
         for (j = 0; j < tag_list_.Count; ++j)
         {
             if (IJStringUtil.CompareString(tag_list_[j].GetRawTag(), tag_set.tag_list_[i].GetRawTag()))
             {
                 break;
             }
         }
         if (j >= tag_list_.Count)
         {
             tag_list_.Add(tag_set.tag_list_[i]);
         }
     }
 }
Пример #25
0
        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];
                    }
                }
            }
        }
Пример #26
0
        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);
                    }
                }
            }
        }
Пример #27
0
        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);
                }
            }
        }
Пример #28
0
        // タグリストから 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(""); // それでも見つからないときは空文字を返す
        }
Пример #29
0
        //private static void ParseRankingHtmlVideoInfo(string html, int index,
        //    out int value,
        //    out DateTime date,
        //    out int view,
        //    out int res,
        //    out int mylist,
        //    out string video_id,
        //    out string title)
        //{
        //    int ps = html.IndexOf("watch/", index) + 6;
        //    int pe = html.IndexOf('"', ps);
        //    video_id = html.Substring(ps, pe - ps);

        //    index = html.IndexOf("<strong", index) + 1;
        //    string value_str = IJStringUtil.GetStringBetweenTag(ref index, "span", html);

        //    string date_str = IJStringUtil.GetStringBetweenTag(ref index, "strong", html);

        //    // ニコニコ動画(9)のランキングHTMLにはランキング対象の期間ポイント以外は表示されない
        //    string view_str = "0";
        //    string res_str = "0";
        //    string mylist_str = "0";

        //    title = IJStringUtil.GetStringBetweenTag(ref index, "a", html);

        //    value = IJStringUtil.ToIntFromCommaValue(value_str);
        //    date = NicoUtil.StringToDate(date_str);
        //    view = IJStringUtil.ToIntFromCommaValue(view_str);
        //    res = IJStringUtil.ToIntFromCommaValue(res_str);
        //    mylist = IJStringUtil.ToIntFromCommaValue(mylist_str);
        //}

        //HTMLランキングファイル動画情報取得 GINZA対応 2013/10/14 marky
        private static void ParseRankingHtmlVideoInfo(string html, int index,
                                                      out int value,
                                                      out DateTime date,
                                                      out int view,
                                                      out int res,
                                                      out int mylist,
                                                      out string video_id,
                                                      out string title)
        {
            //ポイント
            int    ps        = html.IndexOf("rankingPt\">+", index) + 12;
            int    pe        = html.IndexOf('<', ps);
            string value_str = html.Substring(ps, pe - ps);

            //投稿日時
            string date_str = IJStringUtil.GetStringBetweenTag(ref index, "span", html);

            //動画ID
            ps       = html.IndexOf("data-id=\"", index) + 9;
            pe       = html.IndexOf('"', ps);
            video_id = html.Substring(ps, pe - ps);

            //タイトル
            index = html.IndexOf("<p class=\"itemTitle ranking\">", index) + 1;
            title = IJStringUtil.GetStringBetweenTag(ref index, "a", html);

            // ニコニコ動画(9)のランキングHTMLにはランキング対象の期間ポイント以外は表示されない
            string view_str   = "0";
            string res_str    = "0";
            string mylist_str = "0";

            value = IJStringUtil.ToIntFromCommaValue(value_str);
            //date = NicoUtil.StringToDate(date_str);
            date   = DateTime.ParseExact(date_str, "yyyy/MM/dd HH:mm", null);
            view   = IJStringUtil.ToIntFromCommaValue(view_str);
            res    = IJStringUtil.ToIntFromCommaValue(res_str);
            mylist = IJStringUtil.ToIntFromCommaValue(mylist_str);
        }
Пример #30
0
        /// <summary>
        /// フィルターを解析する(フィルターを使う前にこの関数を呼び出す必要がある)
        /// </summary>
        /// <param name="str">フィルターファイルの中身</param>
        public void Parse(string str)
        {
            string[] line = IJStringUtil.SplitWithCRLFAndEraseComment(str);

            int start_blacket = -1;

            for (int i = 0; i < line.Length; ++i)
            {
                if (line[i].StartsWith("["))
                {
                    if (start_blacket >= 0) // 最初は無視
                    {
                        element_list_.Add(FilterElementFactory.MakeElement(line, start_blacket, i));
                    }
                    start_blacket = i;
                }
            }
            // 最後のブロックの処理
            if (start_blacket >= 0)
            {
                element_list_.Add(FilterElementFactory.MakeElement(line, start_blacket, line.Length));
            }
        }