import saccubus.converter.filegetter.FileInstanciator;
import java.io.File;
import java.io.IOException;
+import java.util.concurrent.Callable;
import saccubus.ConvertStopFlag;
import saccubus.net.TextProgressListener;
* @author \96¢\93ü\97Í
* @version 1.0
*/
-public class Converter extends AbstractCommand implements Runnable {
+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;
Setting = setting;
}
- @Override
+ public Boolean call() throws Exception {
+ boolean result = false;
+ try {
+ result = runConvert();
+ } finally {
+ getStopFlag().finished();
+ }
+ return Boolean.valueOf(result);
+ }
+
public void run() {
try {
- runConvert();
+ call();
} catch (Exception ex) {
String text = (ex.getMessage() != null) ? ex.getMessage() : "\97\\8aú\82µ\82È\82¢\83G\83\89\81[\94\90¶\82Ì\82½\82ß\92\86\92f\82µ\82Ü\82µ\82½\81B";
sendText(text);
ex.printStackTrace();
- } finally {
- getStopFlag().finished();
}
}
- private void runConvert() throws IOException, InterruptedException {
+ private boolean runConvert() throws IOException, InterruptedException {
if (!Setting.shouldRun()) {
sendText("\89½\82à\82·\82é\82±\82Æ\82ª\82 \82è\82Ü\82¹\82ñ");
- return;
+ return true;
}
validSetting();
if (!Setting.needsConvert()) {
sendText("\93®\89æ\81E\83R\83\81\83\93\83g\82ð\95Û\91¶\82µ\81A\95Ï\8a·\82Í\8ds\82¢\82Ü\82¹\82ñ\82Å\82µ\82½\81B");
- return;
+ return true;
}
if (!videoFile.isFile()) {
}
boolean res = new FfmpegCommand(getListener(), getStopFlag(), commentFile, tcommFile, videoFile,
- convertedVideoFile, Setting.getFfmpeg()).execute();
+ convertedVideoFile, Setting.getFfmpeg(), Setting.getGeneralSetting()).execute();
if (res) {
if (Setting.getCommentSetting().isDelete()) {
commentFile.delete();
tcommFile.delete();
}
}
+ return res;
}
private FileInstanciator createInstanciator() throws IOException {