Beispiel #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);
                }
            }
        }
Beispiel #2
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);
        }
Beispiel #3
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;
            }
        }
Beispiel #4
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);
                }
            }
        }
Beispiel #5
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;
            }
        }
Beispiel #6
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);
        }
Beispiel #7
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("ファイルの名前の形式が正しくありません");
                }
            }
        }