• R/O
  • SSH
  • HTTPS

nicorank: Commit


Commit MetaInfo

Revision244 (tree)
Zeit2014-11-24 19:47:18
Autorrankingloid

Log Message

Cope with Niconico GINZA version (Thanks to Asarima-san and marky-san)

Ändern Zusammenfassung

Diff

--- trunk/nicorank/nicorank/NicoTools/NicoNetworkManager.cs (revision 243)
+++ trunk/nicorank/nicorank/NicoTools/NicoNetworkManager.cs (revision 244)
@@ -1,4 +1,4 @@
1-// Copyright (c) 2008 - 2009 rankingloid
1+// Copyright (c) 2008 - 2013 rankingloid
22 //
33 // under GNU General Public License Version 2.
44 //
@@ -821,6 +821,7 @@
821821
822822 // 前から start_num - 1 件は捨てる
823823 // start_num が -1 なら全件登録
824+ // (Thanks to Asarima-san and marky-san)
824825 public static List<Video> ParseSearch(string html, int start_num)
825826 {
826827 int index = -1;
@@ -827,35 +828,49 @@
827828 List<Video> list = new List<Video>();
828829 int count = 0;
829830
830- while ((index = html.IndexOf("thumb_col_1\">", index + 1)) >= 0)
831+ while ((index = html.IndexOf("videoList01Wrap\">", index + 1)) >= 0)
831832 {
832833 Video video = new Video();
833834
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+ }
835841
842+ //動画ID
836843 int start = html.IndexOf("watch/", index) + 6;
837844 int end = html.IndexOf('"', start);
845+ int c = html.IndexOf('?', start);
846+ if (end > c)
847+ {
848+ end = c;
849+ }
838850 video.video_id = html.Substring(start, end - start);
839-
851+
852+ //再生時間
840853 video.length = IJStringUtil.GetStringBetweenTag(ref index, "span", html);
841854
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);
843861 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);
845864 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);
847867 video.point.mylist = IJStringUtil.ToIntFromCommaValue(mylistStr);
848868
849869 // 宣伝ポイント。将来実装するときのため
850870 //string comStr =
851- IJStringUtil.GetStringBetweenTag(ref index, "strong", html); // 読み捨て
871+ IJStringUtil.GetStringBetweenTag(ref index, "a", html); // 読み捨て
852872 //video.com = IJStringUtil.ToIntFromCommaValue(comStr);
853873
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-
859874 ++count;
860875 if (count >= start_num)
861876 {
--- trunk/nicorank/nicorank/NicoTools/NicoListManager.cs (revision 243)
+++ trunk/nicorank/nicorank/NicoTools/NicoListManager.cs (revision 244)
@@ -546,12 +546,47 @@
546546 {
547547 int index = -1;
548548
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)
550552 {
551553 yield return index;
552554 }
553555 }
554556
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
555590 private static void ParseRankingHtmlVideoInfo(string html, int index,
556591 out int value,
557592 out DateTime date,
@@ -561,24 +596,31 @@
561596 out string video_id,
562597 out string title)
563598 {
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);
566610 video_id = html.Substring(ps, pe - ps);
567611
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);
570615
571- string date_str = IJStringUtil.GetStringBetweenTag(ref index, "strong", html);
572-
573616 // ニコニコ動画(9)のランキングHTMLにはランキング対象の期間ポイント以外は表示されない
574617 string view_str = "0";
575618 string res_str = "0";
576619 string mylist_str = "0";
577620
578- title = IJStringUtil.GetStringBetweenTag(ref index, "a", html);
579-
580621 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);
582624 view = IJStringUtil.ToIntFromCommaValue(view_str);
583625 res = IJStringUtil.ToIntFromCommaValue(res_str);
584626 mylist = IJStringUtil.ToIntFromCommaValue(mylist_str);
--- trunk/nicorank/nicorank/NicoTools/NicoNetwork.cs (revision 243)
+++ trunk/nicorank/nicorank/NicoTools/NicoNetwork.cs (revision 244)
@@ -1583,12 +1583,13 @@
15831583 /// <summary>
15841584 /// ニコニコ動画公式ランキングをダウンロードする時に、種類を指定するためのクラス
15851585 /// </summary>
1586+ // (Thanks to Asarima-san)
15861587 public class DownloadKind
15871588 {
15881589 public enum FormatKind { Html, Rss };
15891590
15901591 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" };
15921593 protected static string[] duration_name = { "total", "monthly", "weekly", "daily", "hourly" };
15931594 protected static string[] duration_short_name = { "tot", "mon", "wek", "day", "hou" };
15941595
Show on old repository browser