OSDN Git Service

Merge branch 'master'
[coroid/inqubus.git] / frontend / src / saccubus / converter / filegetter / CommentFileWebGetter.java
index 5fd2d35..01afc36 100644 (file)
@@ -2,6 +2,7 @@ package saccubus.converter.filegetter;
 
 import java.io.File;
 import java.io.IOException;
+import saccubus.net.CommentInfo;
 import saccubus.net.NicoClient;
 import saccubus.net.TextProgressListener;
 import saccubus.net.VideoInfo;
@@ -14,24 +15,32 @@ public class CommentFileWebGetter extends TcommFileWebGetter {
 
     private final boolean autoCommentNum;
     private final int backComment;
+    private final CommentInfo commentInfo;
 
-    CommentFileWebGetter(NicoClient client, VideoInfo vi, boolean autoCommentNum, int backComment) {
+    CommentFileWebGetter(NicoClient client, VideoInfo vi, CommentInfo ci, boolean autoCommentNum, int backComment) {
         super(client, vi);
         this.autoCommentNum = autoCommentNum;
         this.backComment = backComment;
+        this.commentInfo = ci;
     }
 
     @Override
     public File get(File file, TextProgressListener listener) throws IOException {
-        String com = Integer.toString(backComment);
+        int com;
         if (this.autoCommentNum) {
-            com = getClient().getBackCommentFromLength(getVideoInfo(), com);
+            com = getVideoInfo().getBackCommentFromLength();
+        } else {
+            com = backComment;
         }
 
-        File res = getClient().getComment(getVideoInfo(), file, listener, com);
+        File res = getClient().getComment(getVideoInfo(), getCommentInfo(), file, listener, com);
         if (res == null) {
             throw new IOException("コメントファイルのダウンロードに失敗しました。");
         }
         return res;
     }
+
+    private CommentInfo getCommentInfo() {
+        return commentInfo;
+    }
 }