OSDN Git Service

新しい仕様のAPIを読んでコメントをダウンロードするように変更
authoryukihane <yukihane.feather@gmail.com>
Mon, 15 Aug 2011 00:42:13 +0000 (09:42 +0900)
committeryukihane <yukihane.feather@gmail.com>
Mon, 15 Aug 2011 02:02:29 +0000 (11:02 +0900)
src/nicobrowser/NicoHttpClient.java

index 963906b..38afcbc 100644 (file)
@@ -794,16 +794,26 @@ public class NicoHttpClient {
     }
 
     public File getTCommentFile(VideoInfo vi, String fileName) throws Exception {
-        return downloadComment(vi, fileName, true, null);
+        return downloadComment(vi, fileName, true, null, true);
     }
 
     private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm, WayBackInfo wayback) throws Exception {
+        return downloadComment(vi, fileName, isTcomm, wayback, false);
+    }
+
+    private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm, WayBackInfo wayback, boolean oldVersion)
+            throws Exception {
         HttpResponse response = null;
         BufferedOutputStream bos = null;
 
         try {
             final HttpPost post = new HttpPost(vi.getMessageUrl().toString());
-            final String param = createCommendDownloadParameter20101222(vi, isTcomm, wayback);
+            final String param;
+            if (oldVersion || isTcomm) {
+                param = createCommendDownloadParameter20101222(vi, isTcomm, wayback);
+            } else {
+                param = createCommendDownloadParameter(vi, wayback);
+            }
             final StringEntity se = new StringEntity(param);
             post.setEntity(se);
             response = http.execute(post);
@@ -832,7 +842,7 @@ public class NicoHttpClient {
         }
     }
 
-    private String createCommendDownloadParameter(VideoInfo vi, boolean isTcomm, WayBackInfo wayback) {
+    private String createCommendDownloadParameter(VideoInfo vi, WayBackInfo wayback) {
         final String quote = "\"";
         final Map<String, String> th = new HashMap<String, String>();
         th.put("thread", vi.getThreadId());