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()) {
- throw new IOException("\93ü\97Í\93®\89æ\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ:" + videoFile.getPath());
+ throw new IOException("\93ü\97Í\93®\89æ\83t\83@\83C\83\8b\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ:" + videoFile.getPath());
}
if (Setting.getOutputFileSetting().isAddComment()) {
if (Setting.getOutputFileSetting().isAddTcomment()) {
if (!tcommFile.isFile()) {
- throw new IOException("\93ü\97Í\93\8a\8de\8eÒ\83R\83\81\83\93\83g\83t\83@\83C\83\8b\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ:" + tcommFile.getPath());
+ throw new IOException("\93ü\97Í\93\8a\8de\8eÒ\83R\83\81\83\93\83g\83t\83@\83C\83\8b\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ" + tcommFile.getPath());
}
} else {
tcommFile = null;
/*\83r\83f\83I\96¼\82Ì\8am\92è*/
File convertedVideoFile;
if (!Setting.getOutputFileSetting().getFile().isFile()) {
- if (fi.getVideoTitle() == null) {
- sendText("\95Ï\8a·\8cã\82Ì\83r\83f\83I\83t\83@\83C\83\8b\96¼\82ª\8am\92è\82Å\82«\82Ü\82¹\82ñ\81B");
- return;
- }
String conv_name = fi.getVideoTitle();
if (Setting.getOutputFileSetting().isAppendPrefixVideoId()) {
conv_name = getVideoIDWithBracket() + conv_name;
}
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 {