OSDN Git Service

Merge branch 'master'
authoryukihane <yukihane.feather@gmail.com>
Fri, 19 Aug 2011 20:19:39 +0000 (05:19 +0900)
committeryukihane <yukihane.feather@gmail.com>
Fri, 19 Aug 2011 20:19:39 +0000 (05:19 +0900)
Conflicts:
frontend/src/saccubus/converter/Converter.java
frontend/src/saccubus/converter/filegetter/FileInstanciator.java

1  2 
frontend/src/saccubus/MainFrame.java
frontend/src/saccubus/converter/Converter.java
frontend/src/saccubus/converter/classic/profile/CommentGetInfo.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/properties/SProperties.java
frontend/src/yukihane/saccubus/converter/profile/CommentGetInfo.java

@@@ -41,10 -41,11 +41,11 @@@ import javax.swing.JTextField
  import javax.swing.LayoutStyle.ComponentPlacement;
  import javax.swing.SwingUtilities;
  import nicobrowser.entity.NicoContent;
+ import nicobrowser.main.Main;
  import org.apache.commons.lang.StringUtils;
  import saccubus.ConvertStopFlag.State;
 -import saccubus.converter.profile.FfmpegOption;
 -import saccubus.converter.profile.NgSetting;
 +import saccubus.converter.classic.profile.FfmpegOption;
 +import saccubus.converter.classic.profile.NgSetting;
  import saccubus.net.TextProgressListener;
  import saccubus.properties.BasicSetting;
  import saccubus.properties.ConvertSetting;
@@@ -1,13 -1,15 +1,15 @@@
  package saccubus.converter;
  
- import yukihane.saccubus.converter.profile.Profile;
 -import java.util.regex.Matcher;
 -import saccubus.converter.profile.Profile;
 -import saccubus.converter.profile.FfmpegOption;
--import saccubus.converter.filegetter.FileInstanciator;
  import java.io.File;
  import java.io.IOException;
  import java.util.concurrent.Callable;
++import java.util.regex.Matcher;
+ import java.util.regex.Pattern;
  import saccubus.ConvertStopFlag;
- import yukihane.saccubus.converter.profile.FfmpegOption;
++import saccubus.converter.filegetter.FileInstanciator;
  import saccubus.net.TextProgressListener;
++import yukihane.saccubus.converter.profile.FfmpegOption;
++import yukihane.saccubus.converter.profile.Profile;
  
  /**
   * <p>タイトル: さきゅばす</p>
   */
  public class Converter extends AbstractCommand implements Runnable, Callable<Boolean> {
  
-     private static final String VIDEO_URL_PARSER = "http://www.nicovideo.jp/watch/";
 -    private final Profile Setting;
 -    private final String Tag;
 -    private final String Time;
 +    private final Profile profile;
 +    private final String movieId;
 +    private final String time;
  
 -    public Converter(String url, String time, Profile setting,
 +    /**
 +     * コンバータを構築します.
 +     * @param url 対象となる動画のURL.
 +     * @param time
 +     * @param profile
 +     * @param listener
 +     * @param flag
 +     */
 +    public Converter(String url, String time, Profile profile,
              TextProgressListener listener, ConvertStopFlag flag) {
          super(listener, flag);
-         url = url.trim();
-         if (url.startsWith(VIDEO_URL_PARSER)) {
-             int index = url.indexOf('?', VIDEO_URL_PARSER.length());
-             if (index >= 0) {
-                 movieId = url.substring(VIDEO_URL_PARSER.length(), index);
-             } else {
-                 movieId = url.substring(VIDEO_URL_PARSER.length());
-             }
+         // TODO 入力欄の値から動画IDの切り出しはGUI側でやるべきだろう
+         final int startIdIdx = url.lastIndexOf("/") + 1;
+         final String altId = url.substring(startIdIdx);
+         final Pattern idPattern = Pattern.compile("([a-z]*\\d+)");
+         final Matcher idMatcher = idPattern.matcher(altId);
+         if (idMatcher.find()) {
 -            Tag = idMatcher.group(1);
++            this.movieId = idMatcher.group(1);
          } else {
-             movieId = url;
+             throw new IllegalArgumentException("URL/IDの指定が不正です: " + url);
          }
 -        Time = time;
 -        Setting = setting;
 +        this.time = time;
 +        this.profile = profile;
      }
  
      public Boolean call() throws Exception {
      private FileInstanciator createInstanciator() throws IOException {
          FileInstanciator fi;
  
 -        FileInstanciator.InstanciationType videoType = new FileInstanciator.InstanciationType(Setting.getVideoSetting());
 +        FileInstanciator.InstanciationType videoType = new FileInstanciator.InstanciationType(profile.getVideoSetting());
  
 -        FileInstanciator.CommentInstanciationType commentType = new FileInstanciator.CommentInstanciationType(Setting.
 -                getCommentSetting(), Setting.getCommentGetInfo().isSelfAdjustCommentNum(), Setting.getCommentGetInfo().
 -                getBackComment(), Setting.getCommentGetInfo().isReduceComment());
 +        FileInstanciator.CommentInstanciationType commentType = new FileInstanciator.CommentInstanciationType(profile.
-                 getCommentSetting(), profile.getCommentGetInfo().isselfAdjustCommentNum(), profile.getCommentGetInfo().
-                 getBackComment());
++                getCommentSetting(), profile.getCommentGetInfo().isSelfAdjustCommentNum(), profile.getCommentGetInfo().
++                getBackComment(), profile.getCommentGetInfo().isReduceComment());
  
          FileInstanciator.InstanciationType tcommType = new FileInstanciator.InstanciationType(
 -                Setting.getTcommentSetting());
 +                profile.getTcommentSetting());
  
 -        fi = FileInstanciator.create(getStopFlag(), videoType, commentType, tcommType, Setting.getLoginInfo(), Tag, Time);
 +        fi = FileInstanciator.create(getStopFlag(), videoType, commentType, tcommType, profile.getLoginInfo(), profile.
 +                getProxySetting(), movieId, time);
          return fi;
      }
  
@@@ -1,24 -1,37 +1,36 @@@
 -/*
 - * To change this template, choose Tools | Templates
 - * and open the template in the editor.
 - */
 -package saccubus.converter.profile;
 +package saccubus.converter.classic.profile;
  
  /**
-  *
+  * コメント取得に関するプロファイルです.
   * @author yuki
   */
 -public class CommentGetInfo {
 +public class CommentGetInfo implements yukihane.saccubus.converter.profile.CommentGetInfo {
  
+     /** コメント取得数を自動調整するのであればtrue. */
      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() {
++    @Override
+     public boolean isSelfAdjustCommentNum() {
          return selfAdjustCommentNum;
      }
  
++    @Override
      public int getBackComment() {
          return backComment;
      }
++    @Override
+     public boolean isReduceComment() {
+         return reduceComment;
+     }
  }
@@@ -47,8 -44,8 +47,8 @@@ public class FileInstanciator 
              String tag, String time) throws
              IOException {
          FileInstanciator getter;
-         if (videoType.isDoanload() || commentType.isDoanload() || tcommType.isDoanload()) {
+         if (videoType.isDownload() || commentType.isDownload() || tcommType.isDownload()) {
 -            getter = new WebFileInstanciator(stopFlag, videoType, commentType, tcommType, li, tag, time);
 +            getter = new WebFileInstanciator(stopFlag, videoType, commentType, tcommType, li, proxy, tag, time);
          } else {
              getter = new FileInstanciator(videoType, commentType, tcommType, tag);
          }
index ab62589,0000000..d3afeb7
mode 100644,000000..100644
--- /dev/null
@@@ -1,12 -1,0 +1,14 @@@
-     boolean isselfAdjustCommentNum();
 +package yukihane.saccubus.converter.profile;
 +
 +/**
 + *
 + * @author yuki
 + */
 +public interface CommentGetInfo {
 +
++    boolean isSelfAdjustCommentNum();
 +
 +    int getBackComment();
++
++    boolean isReduceComment();
 +}