OSDN Git Service

プロファイル見直し
authoryukihane <yukihane.feather@gmail.com>
Mon, 22 Aug 2011 06:00:53 +0000 (15:00 +0900)
committeryukihane <yukihane.feather@gmail.com>
Mon, 22 Aug 2011 06:00:53 +0000 (15:00 +0900)
frontend/src/saccubus/converter/Download.java
frontend/src/saccubus/converter/Ffmpeg.java
frontend/src/saccubus/converter/classic/profile/Ffmpeg.java
frontend/src/saccubus/converter/classic/profile/GeneralSetting.java
frontend/src/saccubus/converter/classic/profile/Profile.java
frontend/src/saccubus/converter/profile/ConvertProfile.java
frontend/src/saccubus/converter/profile/GeneralProfile.java
frontend/src/saccubus/converter/profile/Profile.java

index 149812c..1bb77c4 100644 (file)
@@ -14,7 +14,6 @@ import nicobrowser.WayBackInfo;
 import nicobrowser.entity.NicoContent.Status;
 import org.apache.http.HttpException;
 import saccubus.converter.profile.CommentProfile;
-import saccubus.converter.profile.FfmpegProfile;
 import saccubus.converter.profile.GeneralProfile;
 import saccubus.converter.profile.OutputProfile;
 import saccubus.converter.profile.Profile;
@@ -36,18 +35,18 @@ public class Download extends SwingWorker<DownloadResult, DownloadProgress> impl
 
     private static final Logger logger = Logger.getLogger(Download.class.getName());
     private final Profile profile;
-    private final String movieId;
+    private final String videoId;
 
     /**
      * コンバータを構築します.
-     * @param id 対象となる動画のID.
+     * @param videoId 対象となる動画のID.
      * @param time
      * @param profile
      * @param listener
      * @param flag
      */
-    public Download(String id, Profile profile) {
-        this.movieId = id;
+    public Download(Profile profile, String videoId) {
+        this.videoId = videoId;
         this.profile = profile;
     }
 
@@ -79,20 +78,15 @@ public class Download extends SwingWorker<DownloadResult, DownloadProgress> impl
             return new DownloadResult(true);
         }
 
-        validSetting();
-
-        // TODO ログインしないで良い場合もある.
         publish(new DownloadProgress("ログイン中"));
 
-
-
         NicoHttpClient client = null;
         nicobrowser.VideoInfo vi = null;
         NamePattern videoNamePattern = null;
         WayBackInfo wbi = null;
         if (needsLogin()) {
             client = createClientAndLogin();
-            vi = client.getVideoInfo(movieId);
+            vi = client.getVideoInfo(videoId);
 
             final String name = profile.getVideoSetting().getFileName();
             final String replaceFrom = profile.getGeneralSetting().getReplaceFrom();
@@ -115,7 +109,7 @@ public class Download extends SwingWorker<DownloadResult, DownloadProgress> impl
             final NamePattern pattern = new NamePattern(prof.getFileName(), gene.getReplaceFrom(), gene.getReplaceTo(),
                     vi.getTitleInWatchPage());
             // TODO コメントファイルに{low}は使えないことをどこかに書くべきか
-            final String name = pattern.createFileName(movieId, true);
+            final String name = pattern.createFileName(videoId, true);
             final File file = new File(profile.getCommentSetting().getDir(), name);
 
             commentFile = client.getCommentFile(vi, file.getPath(), wbi, profile.getCommentSetting().
@@ -184,29 +178,30 @@ public class Download extends SwingWorker<DownloadResult, DownloadProgress> impl
         return (profile.getVideoSetting().isDownload() || profile.getCommentSetting().isDownload());
     }
 
+    // TODO どこかに処理を移す必要がある.
     /**
      * (ネットワーク設定以外の)設定を検証する.
      * @throws IllegalArgumentException 設定に不備がある場合.
      */
-    private void validSetting() {
-        if (profile.getOutputFileSetting().isConvert()) {
-            File a = profile.getFfmpeg().getFfmpeg();
-            if (!a.canRead()) {
-                throw new IllegalArgumentException("FFmpegが見つかりません。");
-            }
-            if (profile.getFfmpeg().getVhook().getPath().indexOf(' ') >= 0) {
-                throw new IllegalArgumentException("すいません。現在vhookライブラリには半角空白は使えません。");
-            }
-            a = profile.getFfmpeg().getVhook();
-            if (!a.canRead()) {
-                throw new IllegalArgumentException("Vhookライブラリが見つかりません。");
-            }
-            a = profile.getFfmpeg().getFont();
-            if (!a.canRead()) {
-                throw new IllegalArgumentException("フォントが見つかりません。");
-            }
-        }
-    }
+//    private void validSetting() {
+//        if (profile.getOutputFileSetting().isConvert()) {
+//            File a = profile.getFfmpeg().getFfmpeg();
+//            if (!a.canRead()) {
+//                throw new IllegalArgumentException("FFmpegが見つかりません。");
+//            }
+//            if (profile.getFfmpeg().getVhook().getPath().indexOf(' ') >= 0) {
+//                throw new IllegalArgumentException("すいません。現在vhookライブラリには半角空白は使えません。");
+//            }
+//            a = profile.getFfmpeg().getVhook();
+//            if (!a.canRead()) {
+//                throw new IllegalArgumentException("Vhookライブラリが見つかりません。");
+//            }
+//            a = profile.getFfmpeg().getFont();
+//            if (!a.canRead()) {
+//                throw new IllegalArgumentException("フォントが見つかりません。");
+//            }
+//        }
+//    }
 
     /**
      * HttpClientを生成し, ニコニコ動画サーバへログインします.
@@ -260,7 +255,7 @@ public class Download extends SwingWorker<DownloadResult, DownloadProgress> impl
         final String replaceFrom = gene.getReplaceFrom();
         final String replaceTo = gene.getReplaceTo();
         final NamePattern pattern = new NamePattern(prof.getFileName(), replaceFrom, replaceTo, title);
-        final String name = pattern.createFileName(movieId, isNotLow);
+        final String name = pattern.createFileName(videoId, isNotLow);
         return new File(dir, name);
     }
 
index 89a2cb5..dfaa539 100644 (file)
@@ -38,17 +38,14 @@ public class Ffmpeg extends SwingWorker<FfmpegResult, FfmpegProgress> {
     private final File videoFile;
     private final File convertedVideoFile;
     private final ConvertProfile ffmpeg;
-    private final Profile profile;
 
-    Ffmpeg(File commentFile, File videoFile, File convertedVideoFile, ConvertProfile ffmpeg,
-            GeneralProfile general, Profile profile) throws IOException {
+    Ffmpeg(File commentFile, File videoFile, File convertedVideoFile, ConvertProfile ffmpeg) throws IOException {
         this.commentFile = commentFile;
         this.videoFile = videoFile;
         this.convertedVideoFile = convertedVideoFile;
         this.ffmpeg = ffmpeg;
-        this.profile = profile;
 
-        File tmpDir = general.getTempDir();
+        File tmpDir = ffmpeg.getTempDir();
         commentMiddleFile = File.createTempFile("vhk", ".tmp", tmpDir);
         tcommMiddleFile = File.createTempFile("tcom", ".tmp", tmpDir);
         TMP_CWS = File.createTempFile("cws", ".swf", tmpDir);
@@ -72,7 +69,6 @@ public class Ffmpeg extends SwingWorker<FfmpegResult, FfmpegProgress> {
     }
 
     private FfmpegResult exec() throws InterruptedException, IOException {
-        final FfmpegProfile ov = profile.getFfmpeg().getFfmpegOption();
         final HideCondition ngSetting = getFfmpeg().getNgSetting();
         if (commentFile != null) {
             publish(new FfmpegProgress("コメントの中間ファイルへの変換中"));
index bca978d..51ff9b6 100644 (file)
@@ -88,4 +88,9 @@ public class Ffmpeg implements saccubus.converter.profile.ConvertProfile {
     public HideCondition getNgSetting() {
         return ngSetting;
     }
+
+    @Override
+    public File getTempDir() {
+        return new File(".");
+    }
 }
index 2bd004c..d9231d8 100644 (file)
@@ -12,11 +12,6 @@ public class GeneralSetting implements saccubus.converter.profile.GeneralProfile
     }
 
     @Override
-    public File getTempDir() {
-        return tempDir;
-    }
-
-    @Override
     public String getReplaceFrom() {
         throw new UnsupportedOperationException("Not supported yet.");
     }
index 0dfa463..08a40fd 100644 (file)
@@ -76,11 +76,6 @@ public class Profile implements saccubus.converter.profile.Profile {
     }
 
     @Override
-    public Ffmpeg getFfmpeg() {
-        return ffmpeg;
-    }
-
-    @Override
     public GeneralSetting getGeneralSetting() {
         return generalSetting;
     }
index 0e18268..cb2ed1e 100644 (file)
@@ -19,6 +19,9 @@ public interface ConvertProfile {
     /** @return 拡張ライブラリファイル. */
     File getVhook();
 
+    /** @return 一時作業ディレクトリ. */
+    File getTempDir();
+
     /** @return 使用するフォントファイル. */
     File getFont();
 
index 75f2f9e..6de4509 100644 (file)
@@ -17,6 +17,4 @@ public interface GeneralProfile {
      */
     String getReplaceTo();
 
-    /** @return 作業用一時ディレクトリ. */
-    File getTempDir();
 }
index 2f32657..9fb719c 100644 (file)
@@ -18,7 +18,5 @@ public interface Profile {
 
     OutputProfile getOutputFileSetting();
 
-    ConvertProfile getFfmpeg();
-
     GeneralProfile getGeneralSetting();
 }