package saccubus.converter;
-import saccubus.converter.profile.Profile;
-import saccubus.converter.profile.FfmpegOption;
+import yukihane.saccubus.converter.profile.Profile;
import saccubus.converter.filegetter.FileInstanciator;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.Callable;
import saccubus.ConvertStopFlag;
+import yukihane.saccubus.converter.profile.FfmpegOption;
import saccubus.net.TextProgressListener;
/**
* コンバータを構築します.
* @param url 対象となる動画のURL.
* @param time
- * @param setting
+ * @param profile
* @param listener
- * @param flag
+ * @param flag
*/
- public Converter(String url, String time, Profile setting,
+ public Converter(String url, String time, Profile profile,
TextProgressListener listener, ConvertStopFlag flag) {
super(listener, flag);
url = url.trim();
movieId = url;
}
this.time = time;
- this.profile = setting;
+ this.profile = profile;
}
public Boolean call() throws Exception {
}
private boolean runConvert() throws IOException, InterruptedException {
- if (!profile.shouldRun()) {
+ if (!shouldRun(profile)) {
sendText("何もすることがありません");
return true;
}
boolean res = new FfmpegCommand(getListener(), getStopFlag(), commentFile, tcommFile, videoFile,
convertedVideoFile, profile.getFfmpeg(), profile.getGeneralSetting()).execute();
- if (res) {
- if (profile.getCommentSetting().isDelete()) {
- commentFile.delete();
- }
- if (profile.getVideoSetting().isDelete()) {
- videoFile.delete();
- }
- if (profile.getTcommentSetting().isDelete()) {
- tcommFile.delete();
- }
- }
return res;
}
FileInstanciator.InstanciationType tcommType = new FileInstanciator.InstanciationType(
profile.getTcommentSetting());
- fi = FileInstanciator.create(getStopFlag(), videoType, commentType, tcommType, profile.getLoginInfo(), movieId, time);
+ fi = FileInstanciator.create(getStopFlag(), videoType, commentType, tcommType, profile.getLoginInfo(), profile.
+ getProxySetting(), movieId, time);
return fi;
}
if (!a.canRead()) {
throw new IllegalArgumentException("フォントが見つかりません。");
}
- } else {
- if (profile.getVideoSetting().isDelete()) {
- throw new IllegalArgumentException("変換しないのに、動画削除しちゃって良いんですか?");
- }
- if (profile.getCommentSetting().isDelete()) {
- throw new IllegalArgumentException("変換しないのに、コメント削除しちゃって良いんですか?");
- }
- if (profile.getTcommentSetting().isDelete()) {
- throw new IllegalArgumentException("変換しないのに、投稿者コメント削除しちゃって良いんですか?");
- }
}
}
public ConvertStopFlag getStopFlag() {
return super.getStopFlag();
}
+
+ /** @return 何か実行すべき処理があればtrue. */
+ private static boolean shouldRun(Profile profile) {
+ return profile.getOutputFileSetting().isConvert() || needsDownload(profile);
+ }
+
+ /** @return 何かダウンロードするものがあればtrue. */
+ private static boolean needsDownload(Profile profile) {
+ return (profile.getVideoSetting().isDownload() || profile.getCommentSetting().isDownload() || profile.
+ getTcommentSetting().isDownload());
+ }
}