OSDN Git Service

フィールド名修正
authoryukihane <yukihane.feather@gmail.com>
Wed, 8 Jun 2011 16:25:44 +0000 (01:25 +0900)
committeryukihane <yukihane.feather@gmail.com>
Wed, 8 Jun 2011 16:27:07 +0000 (01:27 +0900)
frontend/src/saccubus/converter/Converter.java

index e619fd5..d2a3868 100644 (file)
@@ -24,9 +24,9 @@ import saccubus.net.TextProgressListener;
 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;
 
     /**
      * コンバータを構築します.
@@ -43,15 +43,15 @@ public class Converter extends AbstractCommand implements Runnable, Callable<Boo
         if (url.startsWith(VIDEO_URL_PARSER)) {
             int index = url.indexOf('?', VIDEO_URL_PARSER.length());
             if (index >= 0) {
-                Tag = url.substring(VIDEO_URL_PARSER.length(), index);
+                movieId = url.substring(VIDEO_URL_PARSER.length(), index);
             } else {
-                Tag = url.substring(VIDEO_URL_PARSER.length());
+                movieId = url.substring(VIDEO_URL_PARSER.length());
             }
         } else {
-            Tag = url;
+            movieId = url;
         }
-        Time = time;
-        Setting = setting;
+        this.time = time;
+        this.profile = setting;
     }
 
     public Boolean call() throws Exception {
@@ -75,13 +75,13 @@ public class Converter extends AbstractCommand implements Runnable, Callable<Boo
     }
 
     private boolean runConvert() throws IOException, InterruptedException {
-        if (!Setting.shouldRun()) {
+        if (!profile.shouldRun()) {
             sendText("何もすることがありません");
             return true;
         }
 
         validSetting();
-        final FfmpegOption ov = Setting.getFfmpeg().getFfmpegOption();
+        final FfmpegOption ov = profile.getFfmpeg().getFfmpegOption();
 
         sendText("ログイン中");
 
@@ -99,7 +99,7 @@ public class Converter extends AbstractCommand implements Runnable, Callable<Boo
 
         File tcommFile = fi.getTcommFile(getListener());
 
-        if (!Setting.needsConvert()) {
+        if (!profile.needsConvert()) {
             sendText("動画・コメントを保存し、変換は行いませんでした。");
             return true;
         }
@@ -108,7 +108,7 @@ public class Converter extends AbstractCommand implements Runnable, Callable<Boo
             throw new IOException("入力動画ファイルが存在しません:" + videoFile.getPath());
         }
 
-        if (Setting.getOutputFileSetting().isAddComment()) {
+        if (profile.getOutputFileSetting().isAddComment()) {
             if (!commentFile.isFile()) {
                 throw new IOException("入力コメントファイルが存在しません:" + commentFile.getPath());
             }
@@ -116,7 +116,7 @@ public class Converter extends AbstractCommand implements Runnable, Callable<Boo
             commentFile = null;
         }
 
-        if (Setting.getOutputFileSetting().isAddTcomment()) {
+        if (profile.getOutputFileSetting().isAddTcomment()) {
             if (!tcommFile.isFile()) {
                 throw new IOException("入力投稿者コメントファイルが存在しません" + tcommFile.getPath());
             }
@@ -126,33 +126,33 @@ public class Converter extends AbstractCommand implements Runnable, Callable<Boo
 
         /*ビデオ名の確定*/
         File convertedVideoFile;
-        if (!Setting.getOutputFileSetting().getFile().isFile()) {
+        if (!profile.getOutputFileSetting().getFile().isFile()) {
             String conv_name = fi.getVideoTitle();
-            if (Setting.getOutputFileSetting().isAppendPrefixVideoId()) {
+            if (profile.getOutputFileSetting().isAppendPrefixVideoId()) {
                 conv_name = getVideoIDWithBracket() + conv_name;
             }
-            convertedVideoFile = new File(Setting.getOutputFileSetting().getFile().getFile(),
+            convertedVideoFile = new File(profile.getOutputFileSetting().getFile().getFile(),
                     conv_name + ov.getExtOption());
         } else {
-            String filename = Setting.getOutputFileSetting().getFile().getFile().getPath();
+            String filename = profile.getOutputFileSetting().getFile().getFile().getPath();
             if (!filename.endsWith(ov.getExtOption())) {
                 filename = filename.substring(0, filename.lastIndexOf('.')) + ov.getExtOption();
                 convertedVideoFile = new File(filename);
             } else {
-                convertedVideoFile = Setting.getOutputFileSetting().getFile().getFile();
+                convertedVideoFile = profile.getOutputFileSetting().getFile().getFile();
             }
         }
 
         boolean res = new FfmpegCommand(getListener(), getStopFlag(), commentFile, tcommFile, videoFile,
-                convertedVideoFile, Setting.getFfmpeg(), Setting.getGeneralSetting()).execute();
+                convertedVideoFile, profile.getFfmpeg(), profile.getGeneralSetting()).execute();
         if (res) {
-            if (Setting.getCommentSetting().isDelete()) {
+            if (profile.getCommentSetting().isDelete()) {
                 commentFile.delete();
             }
-            if (Setting.getVideoSetting().isDelete()) {
+            if (profile.getVideoSetting().isDelete()) {
                 videoFile.delete();
             }
-            if (Setting.getTcommentSetting().isDelete()) {
+            if (profile.getTcommentSetting().isDelete()) {
                 tcommFile.delete();
             }
         }
@@ -162,16 +162,16 @@ public class Converter extends AbstractCommand implements Runnable, Callable<Boo
     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().
+        FileInstanciator.CommentInstanciationType commentType = new FileInstanciator.CommentInstanciationType(profile.
+                getCommentSetting(), profile.getCommentGetInfo().isselfAdjustCommentNum(), profile.getCommentGetInfo().
                 getBackComment());
 
         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(), movieId, time);
         return fi;
     }
 
@@ -180,37 +180,37 @@ public class Converter extends AbstractCommand implements Runnable, Callable<Boo
      * @throws IllegalArgumentException 設定に不備がある場合.
      */
     private void validSetting() {
-        if (Setting.needsConvert()) {
-            File a = Setting.getFfmpeg().getFfmpeg();
+        if (profile.needsConvert()) {
+            File a = profile.getFfmpeg().getFfmpeg();
             if (!a.canRead()) {
                 throw new IllegalArgumentException("FFmpegが見つかりません。");
             }
-            if (Setting.getFfmpeg().getVhook().getPath().indexOf(' ') >= 0) {
+            if (profile.getFfmpeg().getVhook().getPath().indexOf(' ') >= 0) {
                 throw new IllegalArgumentException("すいません。現在vhookライブラリには半角空白は使えません。");
             }
-            a = Setting.getFfmpeg().getVhook();
+            a = profile.getFfmpeg().getVhook();
             if (!a.canRead()) {
                 throw new IllegalArgumentException("Vhookライブラリが見つかりません。");
             }
-            a = Setting.getFfmpeg().getFont();
+            a = profile.getFfmpeg().getFont();
             if (!a.canRead()) {
                 throw new IllegalArgumentException("フォントが見つかりません。");
             }
         } else {
-            if (Setting.getVideoSetting().isDelete()) {
+            if (profile.getVideoSetting().isDelete()) {
                 throw new IllegalArgumentException("変換しないのに、動画削除しちゃって良いんですか?");
             }
-            if (Setting.getCommentSetting().isDelete()) {
+            if (profile.getCommentSetting().isDelete()) {
                 throw new IllegalArgumentException("変換しないのに、コメント削除しちゃって良いんですか?");
             }
-            if (Setting.getTcommentSetting().isDelete()) {
+            if (profile.getTcommentSetting().isDelete()) {
                 throw new IllegalArgumentException("変換しないのに、投稿者コメント削除しちゃって良いんですか?");
             }
         }
     }
 
     private String getVideoIDWithBracket() {
-        return "[" + Tag + "]";
+        return "[" + movieId + "]";
     }
 
     public boolean isConverted() {