Revision | 244 (tree) |
---|---|
Zeit | 2014-11-24 19:47:18 |
Autor | rankingloid |
Cope with Niconico GINZA version (Thanks to Asarima-san and marky-san)
@@ -1,4 +1,4 @@ | ||
1 | -// Copyright (c) 2008 - 2009 rankingloid | |
1 | +// Copyright (c) 2008 - 2013 rankingloid | |
2 | 2 | // |
3 | 3 | // under GNU General Public License Version 2. |
4 | 4 | // |
@@ -821,6 +821,7 @@ | ||
821 | 821 | |
822 | 822 | // 前から start_num - 1 件は捨てる |
823 | 823 | // start_num が -1 なら全件登録 |
824 | + // (Thanks to Asarima-san and marky-san) | |
824 | 825 | public static List<Video> ParseSearch(string html, int start_num) |
825 | 826 | { |
826 | 827 | int index = -1; |
@@ -827,35 +828,49 @@ | ||
827 | 828 | List<Video> list = new List<Video>(); |
828 | 829 | int count = 0; |
829 | 830 | |
830 | - while ((index = html.IndexOf("thumb_col_1\">", index + 1)) >= 0) | |
831 | + while ((index = html.IndexOf("videoList01Wrap\">", index + 1)) >= 0) | |
831 | 832 | { |
832 | 833 | Video video = new Video(); |
833 | 834 | |
834 | - | |
835 | + //投稿日時 | |
836 | + string dateStr = IJStringUtil.GetStringBetweenTag(ref index, "span", html).Trim(); | |
837 | + if (!DateTime.TryParseExact(dateStr, "MM/dd HH:mm", null, System.Globalization.DateTimeStyles.None, out video.submit_date)) | |
838 | + { | |
839 | + video.submit_date = DateTime.ParseExact(dateStr, "yy/MM/dd HH:mm", null); | |
840 | + } | |
835 | 841 | |
842 | + //動画ID | |
836 | 843 | int start = html.IndexOf("watch/", index) + 6; |
837 | 844 | int end = html.IndexOf('"', start); |
845 | + int c = html.IndexOf('?', start); | |
846 | + if (end > c) | |
847 | + { | |
848 | + end = c; | |
849 | + } | |
838 | 850 | video.video_id = html.Substring(start, end - start); |
839 | - | |
851 | + | |
852 | + //再生時間 | |
840 | 853 | video.length = IJStringUtil.GetStringBetweenTag(ref index, "span", html); |
841 | 854 | |
842 | - string viewStr = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); | |
855 | + index = html.IndexOf("itemContent", index + 1); | |
856 | + //タイトル | |
857 | + video.title = IJStringUtil.UnescapeHtml(IJStringUtil.GetStringBetweenTag(ref index, "a", html)); | |
858 | + | |
859 | + //再生 | |
860 | + string viewStr = IJStringUtil.GetStringBetweenTag(ref index, "span", html); | |
843 | 861 | video.point.view = IJStringUtil.ToIntFromCommaValue(viewStr); |
844 | - string resStr = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); | |
862 | + //コメント | |
863 | + string resStr = IJStringUtil.GetStringBetweenTag(ref index, "span", html); | |
845 | 864 | video.point.res = IJStringUtil.ToIntFromCommaValue(resStr); |
846 | - string mylistStr = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); | |
865 | + //マイリスト | |
866 | + string mylistStr = IJStringUtil.GetStringBetweenTag(ref index, "a", html); | |
847 | 867 | video.point.mylist = IJStringUtil.ToIntFromCommaValue(mylistStr); |
848 | 868 | |
849 | 869 | // 宣伝ポイント。将来実装するときのため |
850 | 870 | //string comStr = |
851 | - IJStringUtil.GetStringBetweenTag(ref index, "strong", html); // 読み捨て | |
871 | + IJStringUtil.GetStringBetweenTag(ref index, "a", html); // 読み捨て | |
852 | 872 | //video.com = IJStringUtil.ToIntFromCommaValue(comStr); |
853 | 873 | |
854 | - string dateStr = IJStringUtil.GetStringBetweenTag(ref index, "strong", html).Trim(); | |
855 | - video.submit_date = DateTime.ParseExact(dateStr, "yyyy年MM月dd日 HH:mm", null); | |
856 | - | |
857 | - video.title = IJStringUtil.UnescapeHtml(IJStringUtil.GetStringBetweenTag(ref index, "a", html)); | |
858 | - | |
859 | 874 | ++count; |
860 | 875 | if (count >= start_num) |
861 | 876 | { |
@@ -546,12 +546,47 @@ | ||
546 | 546 | { |
547 | 547 | int index = -1; |
548 | 548 | |
549 | - while ((index = html.IndexOf("<table width=\"648\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" summary=\"\">", index + 1)) >= 0) | |
549 | + //while ((index = html.IndexOf("<table width=\"648\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" summary=\"\">", index + 1)) >= 0) | |
550 | + //GINZA対応 2013/10/14 UPDATE marky | |
551 | + while ((index = html.IndexOf("<div class=\"rankingNumWrap\">", index + 1)) >= 0) | |
550 | 552 | { |
551 | 553 | yield return index; |
552 | 554 | } |
553 | 555 | } |
554 | 556 | |
557 | + //private static void ParseRankingHtmlVideoInfo(string html, int index, | |
558 | + // out int value, | |
559 | + // out DateTime date, | |
560 | + // out int view, | |
561 | + // out int res, | |
562 | + // out int mylist, | |
563 | + // out string video_id, | |
564 | + // out string title) | |
565 | + //{ | |
566 | + // int ps = html.IndexOf("watch/", index) + 6; | |
567 | + // int pe = html.IndexOf('"', ps); | |
568 | + // video_id = html.Substring(ps, pe - ps); | |
569 | + | |
570 | + // index = html.IndexOf("<strong", index) + 1; | |
571 | + // string value_str = IJStringUtil.GetStringBetweenTag(ref index, "span", html); | |
572 | + | |
573 | + // string date_str = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); | |
574 | + | |
575 | + // // ニコニコ動画(9)のランキングHTMLにはランキング対象の期間ポイント以外は表示されない | |
576 | + // string view_str = "0"; | |
577 | + // string res_str = "0"; | |
578 | + // string mylist_str = "0"; | |
579 | + | |
580 | + // title = IJStringUtil.GetStringBetweenTag(ref index, "a", html); | |
581 | + | |
582 | + // value = IJStringUtil.ToIntFromCommaValue(value_str); | |
583 | + // date = NicoUtil.StringToDate(date_str); | |
584 | + // view = IJStringUtil.ToIntFromCommaValue(view_str); | |
585 | + // res = IJStringUtil.ToIntFromCommaValue(res_str); | |
586 | + // mylist = IJStringUtil.ToIntFromCommaValue(mylist_str); | |
587 | + //} | |
588 | + | |
589 | + //HTMLランキングファイル動画情報取得 GINZA対応 2013/10/14 marky | |
555 | 590 | private static void ParseRankingHtmlVideoInfo(string html, int index, |
556 | 591 | out int value, |
557 | 592 | out DateTime date, |
@@ -561,24 +596,31 @@ | ||
561 | 596 | out string video_id, |
562 | 597 | out string title) |
563 | 598 | { |
564 | - int ps = html.IndexOf("watch/", index) + 6; | |
565 | - int pe = html.IndexOf('"', ps); | |
599 | + //ポイント | |
600 | + int ps = html.IndexOf("rankingPt\">+", index) + 12; | |
601 | + int pe = html.IndexOf('<', ps); | |
602 | + string value_str = html.Substring(ps, pe - ps); | |
603 | + | |
604 | + //投稿日時 | |
605 | + string date_str = IJStringUtil.GetStringBetweenTag(ref index, "span", html); | |
606 | + | |
607 | + //動画ID | |
608 | + ps = html.IndexOf("data-id=\"", index) + 9; | |
609 | + pe = html.IndexOf('"', ps); | |
566 | 610 | video_id = html.Substring(ps, pe - ps); |
567 | 611 | |
568 | - index = html.IndexOf("<strong", index) + 1; | |
569 | - string value_str = IJStringUtil.GetStringBetweenTag(ref index, "span", html); | |
612 | + //タイトル | |
613 | + index = html.IndexOf("<p class=\"itemTitle ranking\">", index) + 1; | |
614 | + title = IJStringUtil.GetStringBetweenTag(ref index, "a", html); | |
570 | 615 | |
571 | - string date_str = IJStringUtil.GetStringBetweenTag(ref index, "strong", html); | |
572 | - | |
573 | 616 | // ニコニコ動画(9)のランキングHTMLにはランキング対象の期間ポイント以外は表示されない |
574 | 617 | string view_str = "0"; |
575 | 618 | string res_str = "0"; |
576 | 619 | string mylist_str = "0"; |
577 | 620 | |
578 | - title = IJStringUtil.GetStringBetweenTag(ref index, "a", html); | |
579 | - | |
580 | 621 | value = IJStringUtil.ToIntFromCommaValue(value_str); |
581 | - date = NicoUtil.StringToDate(date_str); | |
622 | + //date = NicoUtil.StringToDate(date_str); | |
623 | + date = DateTime.ParseExact(date_str, "yyyy/MM/dd HH:mm", null); | |
582 | 624 | view = IJStringUtil.ToIntFromCommaValue(view_str); |
583 | 625 | res = IJStringUtil.ToIntFromCommaValue(res_str); |
584 | 626 | mylist = IJStringUtil.ToIntFromCommaValue(mylist_str); |
@@ -1583,12 +1583,13 @@ | ||
1583 | 1583 | /// <summary> |
1584 | 1584 | /// ニコニコ動画公式ランキングをダウンロードする時に、種類を指定するためのクラス |
1585 | 1585 | /// </summary> |
1586 | + // (Thanks to Asarima-san) | |
1586 | 1587 | public class DownloadKind |
1587 | 1588 | { |
1588 | 1589 | public enum FormatKind { Html, Rss }; |
1589 | 1590 | |
1590 | 1591 | protected static string[] target_name = { "fav", "view", "res", "mylist" }; |
1591 | - protected static string[] target_short_name = { "vie", "res", "myl" }; | |
1592 | + protected static string[] target_short_name = { "fav", "vie", "res", "myl" }; | |
1592 | 1593 | protected static string[] duration_name = { "total", "monthly", "weekly", "daily", "hourly" }; |
1593 | 1594 | protected static string[] duration_short_name = { "tot", "mon", "wek", "day", "hou" }; |
1594 | 1595 |