OSDN Git Service

コメント手動取得数を内部ではintで扱うよう変更
authoryukihane <yukihane.feather@gmail.com>
Mon, 15 Aug 2011 04:23:31 +0000 (13:23 +0900)
committeryukihane <yukihane.feather@gmail.com>
Mon, 15 Aug 2011 05:43:06 +0000 (14:43 +0900)
frontend/src/saccubus/converter/filegetter/CommentFileWebGetter.java
frontend/src/saccubus/net/NicoClient.java
frontend/src/saccubus/net/NicoClientImpl.java
frontend/src/saccubus/net/VideoInfo.java
frontend/src/yukihane/inqubus/saccubus_adapter/NicoBrowserAdapter.java

index 697d599..99b28b5 100644 (file)
@@ -30,9 +30,11 @@ public class CommentFileWebGetter extends TcommFileWebGetter {
 
     @Override
     public File get(File file, TextProgressListener listener) throws IOException {
-        String com = Integer.toString(backComment);
+        int com;
         if (this.autoCommentNum) {
-            com = getBackCommentFromLength(getVideoInfo(), com);
+            com = getVideoInfo().getBackCommentFromLength();
+        } else {
+            com = backComment;
         }
 
         File res = getClient().getComment(getVideoInfo(), getCommentInfo(), file, listener, com);
@@ -42,21 +44,6 @@ public class CommentFileWebGetter extends TcommFileWebGetter {
         return res;
     }
 
-    private String getBackCommentFromLength(VideoInfo vi, String def) {
-        final int videoLength  = vi.getVideoLength();
-               if (videoLength < 0) {
-                       return def;
-               } else if (videoLength >= 0 && videoLength < 60) {
-                       return "100";
-               } else if (videoLength >= 60 && videoLength < 300) {
-                       return "250";
-               } else if (videoLength >= 300 && videoLength < 600) {
-                       return "500";
-               } else {
-                       return "1000";
-               }
-    }
-
     private CommentInfo getCommentInfo() {
         return commentInfo;
     }
index c54f6c8..1ce4b42 100644 (file)
@@ -23,7 +23,7 @@ public interface NicoClient {
 
     File getVideo(VideoInfo videoInfo, File file, TextProgressListener listener);
 
-    File getComment(VideoInfo videoInfo, CommentInfo commentInfo, File file, TextProgressListener listener, String com);
+    File getComment(VideoInfo videoInfo, CommentInfo commentInfo, File file, TextProgressListener listener, int com);
 
     File getTcomment(VideoInfo videoInfo, File file, TextProgressListener listener);
 }
index 1a808b7..7c5dd4f 100644 (file)
@@ -68,7 +68,7 @@ public class NicoClientImpl implements NicoClient {
     }
 
     @Override
-    public File getComment(VideoInfo vi, CommentInfo ci, final File file, final TextProgressListener status, String back_comment) {
+    public File getComment(VideoInfo vi, CommentInfo ci, final File file, final TextProgressListener status, int back_comment) {
         return downloadComment(back_comment, file, vi, ci, status, false);
     }
 
@@ -81,15 +81,15 @@ public class NicoClientImpl implements NicoClient {
      */
     @Override
     public File getTcomment(VideoInfo vi, final File file, final TextProgressListener status) {
-        return downloadComment("500", file, vi, status, true);
+        return downloadComment(1000, file, vi, status, true);
     }
 
-    private File downloadComment(String back_comment, final File file, VideoInfo vi, final TextProgressListener status,
+    private File downloadComment(int back_comment, final File file, VideoInfo vi, final TextProgressListener status,
             boolean isTcomm) throws NumberFormatException {
         return downloadComment(back_comment, file, vi, CommentInfo.DEFAULT, status, isTcomm);
     }
 
-    private File downloadComment(String back_comment, final File file, VideoInfo vi, CommentInfo ci, final TextProgressListener status,
+    private File downloadComment(int back_comment, final File file, VideoInfo vi, CommentInfo ci, final TextProgressListener status,
             boolean isTcomm) throws NumberFormatException {
         System.out.print("Downloading comment size:" + back_comment + "...");
         try {
index 29083e3..9c09def 100644 (file)
@@ -70,6 +70,20 @@ public class VideoInfo {
         return officialOption;
     }
 
+    public int getBackCommentFromLength() {
+        final int length = getVideoLength();
+
+        if (length < 60) {
+            return 100;
+        } else if (length < 300) {
+            return 250;
+        } else if (length < 600) {
+            return 500;
+        } else {
+            return 1000;
+        }
+    }
+
     public static class OfficialOption {
 
         private final String threadKey;
index 0465661..37b2085 100644 (file)
@@ -68,7 +68,7 @@ public class NicoBrowserAdapter implements NicoClient {
 
     @Override
     public File getComment(VideoInfo videoInfo, CommentInfo commentInfo, File file, TextProgressListener listener,
-            String com) {
+            int com) {
         try {
             WayBackInfo wbi = new WayBackInfo(commentInfo.getWayBackKey(), commentInfo.getWayBackTime());
             return client.getCommentFile(nicoBrowserVi, file.getPath(), wbi);