OSDN Git Service

Merge branch 'master'
authoryukihane <yukihane.feather@gmail.com>
Tue, 16 Aug 2011 18:20:24 +0000 (03:20 +0900)
committeryukihane <yukihane.feather@gmail.com>
Tue, 16 Aug 2011 18:20:24 +0000 (03:20 +0900)
Conflicts:
frontend/nbproject/project.properties
frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java

1  2 
frontend/nbproject/project.properties
frontend/src/saccubus/MainFrame.java
frontend/src/saccubus/SavePanel.java
frontend/src/saccubus/converter/FfmpegCommand.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/net/VideoInfo.java
frontend/src/yukihane/nicovideo/NicoDBFinder.java

@@@ -27,9 -27,7 +27,7 @@@ endorsed.classpath
  excludes=\r
  file.reference.jmockit.jar=F:\\data\\java\\jmockit-0.998\\jmockit.jar\r
  includes=**\r
- jar.archive.disabled=${jnlp.enabled}\r
- jar.compress=false\r
- jar.index=${jnlp.enabled}\r
+ jar.compress=true\r
  javac.classpath=\\r
      ${reference.NicoBrowser.jar}:\\r
      ${reference.MediaInfoWrapper.jar}:\\r
@@@ -40,7 -38,6 +38,6 @@@
      ${libs.Commons-Exec.classpath}:\\r
      ${libs.Commons-Collections.classpath}:\\r
      ${libs.toplink.classpath}:\\r
-     ${libs.HttpClient4.0.classpath}:\\r
      ${libs.H2_DB.classpath}:\\r
      ${libs.Commons-CLI.classpath}\r
  # Space-separated list of extra javac options\r
@@@ -55,7 -52,8 +52,8 @@@ javac.test.classpath=
      ${build.classes.dir}:\\r
      ${libs.junit_4.classpath}:\\r
      ${libs.FEST-Swing.classpath}:\\r
-     ${file.reference.jmockit.jar}\r
+     ${file.reference.jmockit.jar}:\\r
+     ${libs.PowerMock-EasyMock.classpath}\r
  javadoc.additionalparam=\r
  javadoc.author=false\r
  javadoc.encoding=${source.encoding}\r
@@@ -71,17 -69,12 +69,16 @@@ jaxbwiz.endorsed.dirs="${netbeans.home}
  jnlp.codebase.type=local\r
  jnlp.descriptor=application\r
  jnlp.enabled=false\r
 +jnlp.mixed.code=default\r
  jnlp.offline-allowed=false\r
  jnlp.signed=false\r
 -main.class=saccubus.Saccubus\r
 +jnlp.signing=\r
 +jnlp.signing.alias=\r
 +jnlp.signing.keystore=\r
 +main.class=yukihane.inqubuss.gui.MainFrame\r
  manifest.file=manifest.mf\r
  meta.inf.dir=${src.dir}/META-INF\r
  mkdist.disabled=false\r
- no.dependencies=true\r
  platform.active=default_platform\r
  project.MediaInfoWrapper=../../MediaInfoWrapper\r
  project.NicoBrowser=../../NicoBrowser\r
@@@ -89,7 -82,11 +86,11 @@@ reference.MediaInfoWrapper.jar=${projec
  reference.NicoBrowser.jar=${project.NicoBrowser}/dist/NicoBrowser.jar\r
  run.classpath=\\r
      ${javac.classpath}:\\r
-     ${build.classes.dir}\r
+     ${build.classes.dir}:\\r
+     ${libs.Rome.classpath}:\\r
+     ${libs.groovy-all.classpath}:\\r
+     ${libs.HttpComponents.classpath}:\\r
+     ${libs.NekoHtml.classpath}\r
  # Space-separated list of JVM arguments used when running the project\r
  # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value\r
  # or test-sys-prop.name=value to set system properties for unit tests):\r
@@@ -43,8 -43,8 +43,8 @@@ import javax.swing.SwingUtilities
  import nicobrowser.entity.NicoContent;
  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;
@@@ -82,7 -82,7 +82,7 @@@ public class MainFrame extends JFrame 
  
      private static final long serialVersionUID = 2564486741331062989L;
      public static final String PRODUCT_NAME = "いんきゅばす";
-     public static final String VERSION = "1.5.0";
+     public static final String VERSION = "1.7.0";
      public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource(
              "icon32.png"));
      // TODO GUIが無いためフィールドに保持.
      private GridBagLayout gridBagLayout12 = new GridBagLayout();
      private JPanel ConvertingSettingPanel = null;
      private JPanel NGWordSettingPanel = null;
-     private JLabel NGWordLavel = null;
+     private JLabel NGWordLabel = null;
      private JTextField ngWordTextField = null;
      private JLabel NGIDLabel = null;
      private JTextField ngIdTextField = null;
              gridBagConstraints2.gridx = 0;
              gridBagConstraints2.insets = new Insets(0, 5, 5, 0);
              gridBagConstraints2.gridy = 0;
-             NGWordLavel = new JLabel();
-             NGWordLavel.setText("NGワード");
+             NGWordLabel = new JLabel();
+             NGWordLabel.setText("NGワード");
              NGWordSettingPanel = new JPanel();
              NGWordSettingPanel.setLayout(new GridBagLayout());
              NGWordSettingPanel.setBorder(BorderFactory.createTitledBorder(null,
-                     "NGワード・ID設定"));
-             NGWordSettingPanel.add(NGWordLavel, gridBagConstraints2);
+                     "NGワード・ID設定(半角スペース区切りで複数入力)"));
+             NGWordSettingPanel.add(NGWordLabel, gridBagConstraints2);
              NGWordSettingPanel.add(getNGWordTextField(), gridBagConstraints3);
              NGWordSettingPanel.add(NGIDLabel, gridBagConstraints4);
              NGWordSettingPanel.add(getNGIDTextField(), gridBagConstraints5);
@@@ -1,4 -1,9 +1,4 @@@
  /*
 - * To change this template, choose Tools | Templates
 - * and open the template in the editor.
 - */
 -
 -/*
   * SavePanel.java
   *
   * Created on 2009/12/04, 21:06:09
@@@ -18,6 -23,7 +18,7 @@@ import javax.swing.JTextField
   * @author yuki
   */
  public class SavePanel extends javax.swing.JPanel {
+     private static final long serialVersionUID = 1L;
  
      private final VideoSaveInfoPanel videoSaveInfoPanel = new VideoSaveInfoPanel();
  
@@@ -9,13 -9,15 +9,15 @@@ import java.io.UnsupportedEncodingExcep
  import java.net.URLEncoder;
  import java.util.ArrayList;
  import java.util.List;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
  import org.apache.commons.lang.StringUtils;
  import saccubus.ConvertStopFlag;
  import saccubus.conv.ConvertToVideoHook;
 -import saccubus.converter.profile.Ffmpeg;
 -import saccubus.converter.profile.FfmpegOption;
 -import saccubus.converter.profile.GeneralSetting;
 -import saccubus.converter.profile.NgSetting;
 +import yukihane.saccubus.converter.profile.NgSetting;
 +import yukihane.saccubus.converter.profile.Ffmpeg;
 +import yukihane.saccubus.converter.profile.FfmpegOption;
 +import yukihane.saccubus.converter.profile.GeneralSetting;
  import saccubus.net.TextProgressListener;
  import yukihane.mediainfowrapper.Info;
  import yukihane.mediainfowrapper.MediaInfo;
@@@ -27,7 -29,7 +29,7 @@@ import yukihane.swf.Cws2Fws
   * @author yuki
   */
  public class FfmpegCommand extends AbstractCommand {
+     private static final Logger logger = Logger.getLogger(FfmpegCommand.class.getName());
      private final File commentMiddleFile;
      private final File tcommMiddleFile;
      private final File TMP_CWS;
  
          cmdList.add(convertedVideoFile.getPath());
  
-         System.out.print("arg:");
+         final StringBuilder argMsg = new StringBuilder();
+         argMsg.append("arg:");
          for (String s : cmdList) {
-             System.out.print(" " + s);
+             argMsg.append(" ").append(s);
          }
-         System.out.println();
+         logger.log(Level.INFO, argMsg.toString());
  
          try {
-             System.out.println("\n\n----\nProcessing FFmpeg...\n----\n\n");
+             logger.log(Level.INFO, "\n\n----\nProcessing FFmpeg...\n----\n\n");
              Process process = Runtime.getRuntime().exec(cmdList.toArray(new String[0]));
              BufferedReader ebr = new BufferedReader(new InputStreamReader(
                      process.getErrorStream()));
                  if (state.startsWith("frame=")) {
                      sendText(state);
                  } else if (!state.endsWith("No accelerated colorspace conversion found")) {
-                     System.out.println(e);
+                     logger.log(Level.INFO, e);
                  }
  
                  try {
@@@ -1,7 -1,12 +1,8 @@@
 -/*
 - * To change this template, choose Tools | Templates
 - * and open the template in the editor.
 - */
  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 -19,32 +15,32 @@@ public class CommentFileWebGetter exten
  
      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;
+     }
  }
@@@ -6,10 -6,8 +6,10 @@@ import java.io.FileNotFoundException
  import java.io.IOException;
  import org.apache.commons.io.FilenameUtils;
  import saccubus.ConvertStopFlag;
 -import saccubus.converter.profile.InputFileSetting;
 +import yukihane.saccubus.converter.profile.InputFileSetting;
  import saccubus.net.TextProgressListener;
 +import yukihane.saccubus.converter.profile.LoginInfo;
 +import yukihane.saccubus.converter.profile.Proxy;
  
  /**
   * ダウンロード処理を全く必要としない場合のファイルインスタンス化クラス.
@@@ -43,12 -41,11 +43,12 @@@ public class FileInstanciator 
              CommentInstanciationType commentType,
              InstanciationType tcommType,
              LoginInfo li,
 +            Proxy proxy,
              String tag, String time) throws
              IOException {
          FileInstanciator getter;
          if (videoType.isDoanload() || commentType.isDoanload() || tcommType.isDoanload()) {
 -            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);
          }
       */
      public final File getTcommFile(TextProgressListener listener) throws IOException {
          File file = new FileLocator(tcommType.isAutoFileName(), tcommType.getInitFile(), getVideoIdWithBracket(),
-                 getVideoTitle(), ".txml").getFile();
+                 getVideoTitle(), ".xml").getFile();
          file = tcommFileGetter.get(file, listener);
          return file;
      }
@@@ -3,11 -3,14 +3,15 @@@ package saccubus.converter.filegetter
  
  import java.io.IOException;
  import java.text.Normalizer;
+ import org.apache.commons.lang.StringUtils;
  import saccubus.ConvertStopFlag;
 -import saccubus.converter.profile.Proxy;
+ import saccubus.net.CommentInfo;
  import saccubus.net.NicoClient;
  import saccubus.net.VideoInfo;
+ import saccubus.util.WayBackTimeParser;
+ import yukihane.inqubus.saccubus_adapter.NicoBrowserAdapter;
 +import yukihane.saccubus.converter.profile.Proxy;
 +import yukihane.saccubus.converter.profile.LoginInfo;
  
  /**
   * 動画ファイル, コメントファイルなど必要なファイルのうち, 1つでもダウンロード処理を必要とする場合のインスタンス化クラス.
@@@ -17,6 -20,7 +21,7 @@@ public class WebFileInstanciator extend
  
      private final NicoClient client;
      private final VideoInfo videoInfo;
+     private final CommentInfo commentInfo;
  
      WebFileInstanciator(
              ConvertStopFlag stopFlag,
@@@ -24,7 -28,6 +29,7 @@@
              CommentInstanciationType commentType,
              InstanciationType tcommType,
              LoginInfo li,
 +            Proxy proxy,
              String tag,
              String time) throws IOException {
          super(videoType, commentType, tcommType, tag);
  
          String host;
          int port;
 -        if (li.getProxy() != Proxy.NO_PROXY) {
 -            host = li.getProxy().getHost();
 -            port = li.getProxy().getPort();
 +        if (proxy.use()) {
 +            host = proxy.getHost();
 +            port = proxy.getPort();
          } else {
              host = null;
              port = -1;
          }
-         client = new NicoClient(li.getMail(), li.getPass(), stopFlag, host, port);
+         client = new NicoBrowserAdapter(li.getMail(), li.getPass(), stopFlag, host, port) {
+         };
  
          if (!client.isLoggedIn()) {
              throw new IOException("ログインに失敗");
          }
  
          try {
-             videoInfo = client.getVideoInfo(tag, time);
+             videoInfo = client.getVideoInfo(tag);
+             if (StringUtils.isNotBlank(time)) {
+                 System.out.print("Setting wayback time...");
+                 final String waybacktime = WayBackTimeParser.parse(time);
+                 String waybackkey = client.getWayBackKey(videoInfo);
+                 commentInfo = new CommentInfo(waybackkey, waybacktime);
+             }else{
+                 commentInfo = null;
+             }
          } catch (IOException ex) {
              throw new IOException(tag + "の情報の取得に失敗", ex);
          }
@@@ -59,7 -72,7 +74,7 @@@
          }
  
          if (commentType.isDoanload()) {
-             setCommentFileGetter(new CommentFileWebGetter(client, videoInfo, commentType.isAutoCommentNum(),
+             setCommentFileGetter(new CommentFileWebGetter(client, videoInfo, commentInfo, commentType.isAutoCommentNum(),
                      commentType.getBackComment()));
          }
  
@@@ -1,3 -1,7 +1,3 @@@
 -/*
 - * To change this template, choose Tools | Templates
 - * and open the template in the editor.
 - */
  package saccubus.net;
  
  /**
@@@ -24,7 -28,7 +24,7 @@@ public class VideoInfo 
       * @param videoLength
       * @param officialOption nullも可.
       */
-     VideoInfo(String videoTitle, String threadId, String videoUrl, String msgUrl, String userId, int videoLength,
+     public VideoInfo(String videoTitle, String threadId, String videoUrl, String msgUrl, String userId, int videoLength,
              OfficialOption officialOption) {
          if (videoTitle == null || threadId == null || videoUrl == null || msgUrl == null || userId == null) {
              throw new IllegalArgumentException("video informationの情報が不正です。");
          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;
          private final String force184;
  
          public OfficialOption(String threadKey, String force184) {
-             if (threadKey == null || force184 == null) {
-                 throw new IllegalArgumentException("公式動画用キーが不正です");
-             }
//            if (threadKey == null || force184 == null) {
//                throw new IllegalArgumentException("公式動画用キーが不正です");
//            }
              this.threadKey = threadKey;
              this.force184 = force184;
          }
@@@ -1,3 -1,7 +1,3 @@@
 -/*
 - * To change this template, choose Tools | Templates
 - * and open the template in the editor.
 - */
  package yukihane.nicovideo;
  
  import java.util.HashMap;
@@@ -42,6 -46,7 +42,7 @@@ public class NicoDBFinder 
          String baseName = FilenameUtils.getBaseName(fileName);
          Query query = manager.createQuery("SELECT cont FROM NicoContent AS cont " + "WHERE ?1 = cont.fileName").
                  setParameter(1, baseName);
+         @SuppressWarnings("unchecked")
          List<NicoContent> results = query.getResultList();
          if (results.size() > 1) {
              Logger.getLogger(getClass().getName()).log(Level.WARNING, "同一ファイル名のファイルが複数ありました");