OSDN Git Service

コメント量を減らすパラメータを渡す処理実装
authoryukihane <yukihane.feather@gmail.com>
Fri, 19 Aug 2011 13:23:45 +0000 (22:23 +0900)
committeryukihane <yukihane.feather@gmail.com>
Fri, 19 Aug 2011 13:23:45 +0000 (22:23 +0900)
frontend/src/saccubus/MainFrame.java
frontend/src/saccubus/converter/Converter.java
frontend/src/saccubus/converter/filegetter/CommentFileWebGetter.java
frontend/src/saccubus/converter/filegetter/FileInstanciator.java
frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java
frontend/src/saccubus/converter/profile/CommentGetInfo.java
frontend/src/saccubus/net/NicoClient.java
frontend/src/saccubus/net/NicoClientImpl.java
frontend/src/saccubus/properties/InputCommentSetting.java
frontend/src/saccubus/properties/SProperties.java
frontend/src/yukihane/inqubus/saccubus_adapter/NicoBrowserAdapter.java

index d47db1b..0ed11bb 100644 (file)
@@ -1390,7 +1390,7 @@ public class MainFrame extends JFrame {
         boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected();
 
         return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom,
-                back_comment);
+                back_comment, reduceCommentCheckBox.isSelected());
     }
 
     /**
index bda3956..2e83404 100644 (file)
@@ -158,7 +158,7 @@ public class Converter extends AbstractCommand implements Runnable, Callable<Boo
 
         FileInstanciator.CommentInstanciationType commentType = new FileInstanciator.CommentInstanciationType(Setting.
                 getCommentSetting(), Setting.getCommentGetInfo().isSelfAdjustCommentNum(), Setting.getCommentGetInfo().
-                getBackComment());
+                getBackComment(), Setting.getCommentGetInfo().isReduceComment());
 
         FileInstanciator.InstanciationType tcommType = new FileInstanciator.InstanciationType(
                 Setting.getTcommentSetting());
index 99b28b5..1a2f432 100644 (file)
@@ -19,12 +19,14 @@ public class CommentFileWebGetter extends TcommFileWebGetter {
 
     private final boolean autoCommentNum;
     private final int backComment;
+    private final boolean reduceComment;
     private final CommentInfo commentInfo;
 
-    CommentFileWebGetter(NicoClient client, VideoInfo vi, CommentInfo ci, boolean autoCommentNum, int backComment) {
+    CommentFileWebGetter(NicoClient client, VideoInfo vi, CommentInfo ci, boolean autoCommentNum, int backComment, boolean reduceComment) {
         super(client, vi);
         this.autoCommentNum = autoCommentNum;
         this.backComment = backComment;
+        this.reduceComment = reduceComment;
         this.commentInfo = ci;
     }
 
@@ -37,7 +39,7 @@ public class CommentFileWebGetter extends TcommFileWebGetter {
             com = backComment;
         }
 
-        File res = getClient().getComment(getVideoInfo(), getCommentInfo(), file, listener, com);
+        File res = getClient().getComment(getVideoInfo(), getCommentInfo(), file, listener, com, reduceComment);
         if (res == null) {
             throw new IOException("コメントファイルのダウンロードに失敗しました。");
         }
index b1750d3..be72e73 100644 (file)
@@ -172,11 +172,14 @@ public class FileInstanciator {
 
         private final boolean autoCommentNum;
         private final int backComment;
+        private final boolean reduceComment;
 
-        public CommentInstanciationType(InputFileSetting fileSetting, boolean autoCommentNum, int backComment) {
+        public CommentInstanciationType(InputFileSetting fileSetting, boolean autoCommentNum, int backComment,
+                boolean reduceComment) {
             super(fileSetting);
             this.autoCommentNum = autoCommentNum;
             this.backComment = backComment;
+            this.reduceComment = reduceComment;
         }
 
         public boolean isAutoCommentNum() {
@@ -186,5 +189,9 @@ public class FileInstanciator {
         public int getBackComment() {
             return backComment;
         }
+
+        boolean isReduceComment() {
+            return reduceComment;
+        }
     }
 }
index 2dd64d2..36f2bfb 100644 (file)
@@ -73,7 +73,7 @@ public class WebFileInstanciator extends FileInstanciator {
 
         if (commentType.isDownload()) {
             setCommentFileGetter(new CommentFileWebGetter(client, videoInfo, commentInfo, commentType.isAutoCommentNum(),
-                    commentType.getBackComment()));
+                    commentType.getBackComment(), commentType.isReduceComment()));
         }
 
         if (tcommType.isDownload()) {
index f0ae930..6392eeb 100644 (file)
@@ -14,10 +14,13 @@ public class CommentGetInfo {
     private final boolean selfAdjustCommentNum;
     /** コメント取得数を自動調整しない場合の取得数. */
     private final int backComment;
+    /** 旧仕様(2010年末までバージョン)でコメントを取得する場合はtrue. */
+    private final boolean reduceComment;
 
-    public CommentGetInfo(boolean selfAdjustCommentNum, int backComment) {
+    public CommentGetInfo(boolean selfAdjustCommentNum, int backComment, boolean reduceComment) {
         this.selfAdjustCommentNum = selfAdjustCommentNum;
         this.backComment = backComment;
+        this.reduceComment = reduceComment;
     }
 
     public boolean isSelfAdjustCommentNum() {
@@ -27,4 +30,8 @@ public class CommentGetInfo {
     public int getBackComment() {
         return backComment;
     }
+
+    public boolean isReduceComment() {
+        return reduceComment;
+    }
 }
index 1ce4b42..add3359 100644 (file)
@@ -23,7 +23,8 @@ public interface NicoClient {
 
     File getVideo(VideoInfo videoInfo, File file, TextProgressListener listener);
 
-    File getComment(VideoInfo videoInfo, CommentInfo commentInfo, File file, TextProgressListener listener, int com);
+    File getComment(VideoInfo videoInfo, CommentInfo commentInfo, File file, TextProgressListener listener,
+            int com, boolean reduceComment);
 
     File getTcomment(VideoInfo videoInfo, File file, TextProgressListener listener);
 }
index e9541f1..7c09a20 100644 (file)
@@ -38,10 +38,11 @@ import static saccubus.net.VideoInfo.OfficialOption;
  * <p>
  * 会社名:
  * </p>
- *
+ * @deprecated 2011/2 以降のコメントダウンロード仕様には対応していません.
  * @author 未入力
  * @version 1.0
  */
+@Deprecated
 public class NicoClientImpl implements NicoClient {
 
     private String Cookie = null;
@@ -67,8 +68,12 @@ public class NicoClientImpl implements NicoClient {
         StopFlag = flag;
     }
 
+    /**
+     * @deprecated reduceComment は無視されます(常にtrueの動作をします).
+     */
     @Override
-    public File getComment(VideoInfo vi, CommentInfo ci, final File file, final TextProgressListener status, int back_comment) {
+    public File getComment(VideoInfo vi, CommentInfo ci, final File file, final TextProgressListener status,
+            int back_comment, boolean reduceComment) {
         return downloadComment(back_comment, file, vi, ci, status, false);
     }
 
@@ -89,7 +94,8 @@ public class NicoClientImpl implements NicoClient {
         return downloadComment(back_comment, file, vi, null, status, isTcomm);
     }
 
-    private File downloadComment(int 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 6e8db98..8b52e05 100644 (file)
@@ -26,14 +26,17 @@ public class InputCommentSetting extends InputFileSetting<Boolean> {
     private static final String PROP_COMMENT_FILE = "CommentFile";
     private final boolean selfAdjustNumOfComment;
     private final int numOfComment;
+    private final boolean reduceComment;
 
     public InputCommentSetting(boolean download, boolean autoNaming, File folder, File file, boolean deleteAfterConvert,
-            boolean adjust, int numOfCom) {
+            boolean adjust, int numOfCom, boolean reduceComment) {
         super(Boolean.valueOf(download), autoNaming, folder, file, deleteAfterConvert);
         this.selfAdjustNumOfComment = adjust;
         this.numOfComment = numOfCom;
+        this.reduceComment = reduceComment;
     }
 
+    @Override
     public void save(Properties prop) {
         prop.setProperty(PROP_SAVE_COMMENT, getProcessKind().toString());
         prop.setProperty(PROP_DEL_COMMENT_AFTER_CONV, Boolean.toString(isDeleteAfterConvert()));
@@ -56,7 +59,7 @@ public class InputCommentSetting extends InputFileSetting<Boolean> {
 
         return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete,
                 adjustNumOfComment,
-                Integer.parseInt(numOfComment));
+                Integer.parseInt(numOfComment), false);
     }
 
     public final boolean isSelfAdjustNumOfComment() {
@@ -66,4 +69,8 @@ public class InputCommentSetting extends InputFileSetting<Boolean> {
     public final int getNumOfComment() {
         return numOfComment;
     }
+
+    public boolean isReduceComment(){
+        return reduceComment;
+    }
 }
index 5b60a75..a6d3948 100644 (file)
@@ -151,7 +151,7 @@ public class SProperties {
 
         private CommentGetInfo buildCommentGetInfo() {
             final InputCommentSetting setting = getInputCommentSetting();
-            return new CommentGetInfo(setting.isSelfAdjustNumOfComment(), setting.getNumOfComment());
+            return new CommentGetInfo(setting.isSelfAdjustNumOfComment(), setting.getNumOfComment(), setting.isReduceComment());
         }
 
         private InputFileSetting buildTcommentSetting() {
index 68cd4d0..9bcdbcb 100644 (file)
@@ -68,11 +68,11 @@ public class NicoBrowserAdapter implements NicoClient {
 
     @Override
     public File getComment(VideoInfo videoInfo, CommentInfo commentInfo, File file, TextProgressListener listener,
-            int commentNum) {
+            int commentNum, boolean reduceComment) {
         try {
             final WayBackInfo wbi = (commentInfo != null) ? new WayBackInfo(commentInfo.getWayBackKey(), commentInfo.
                     getWayBackTime()) : null;
-            return client.getCommentFile(nicoBrowserVi, file.getPath(), wbi, commentNum);
+            return client.getCommentFile(nicoBrowserVi, file.getPath(), wbi, commentNum, reduceComment);
         } catch (Exception ex) {
             logger.log(Level.SEVERE, "コメント取得失敗", ex);
         }