Exemple #1
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);
                }
            }
        }
Exemple #2
0
 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]);
 }
Exemple #3
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);
                }
            }
        }
Exemple #4
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);
                }
            }
        }
Exemple #5
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);
                    }
                }
            }
        }
Exemple #6
0
        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];
            }
        }
Exemple #7
0
        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;
            }
        }
Exemple #8
0
        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("ファイルの名前の形式が正しくありません");
                }
            }
        }
Exemple #9
0
 public void SetDateTo(string str)
 {
     date_to = NicoUtil.StringToDate(str);
 }
Exemple #10
0
 public void SetDateFrom(string str)
 {
     date_from = NicoUtil.StringToDate(str);
 }