import saccubus.worker.profile.CommentProfile;
import saccubus.worker.profile.GeneralProfile;
import saccubus.worker.profile.OutputProfile;
-import saccubus.worker.profile.Profile;
+import saccubus.worker.profile.DownloadProfile;
import saccubus.worker.profile.ProxyProfile;
/**
public class Download extends SwingWorker<DownloadResult, DownloadProgress> implements Callable<Boolean> {
private static final Logger logger = Logger.getLogger(Download.class.getName());
- private final Profile profile;
+ private final DownloadProfile profile;
private final String videoId;
/**
* @param listener
* @param flag
*/
- public Download(Profile profile, String videoId) {
+ public Download(DownloadProfile profile, String videoId) {
this.videoId = videoId;
this.profile = profile;
}
// }
@Override
protected DownloadResult doInBackground() throws Exception {
- if (!shouldRun(profile)) {
+ if (!needsDownload(profile)) {
publish(new DownloadProgress("何もすることがありません"));
return new DownloadResult(true);
}
} else {
videoFile = profile.getVideoSetting().getLocalFile();
}
-
- if (!profile.getOutputFileSetting().isConvert()) {
- publish(new DownloadProgress("動画・コメントを保存し、変換は行いませんでした。"));
- return new DownloadResult(true);
- }
-
- if (!videoFile.isFile()) {
- throw new IOException("入力動画ファイルが存在しません:" + videoFile.getPath());
- }
-
- if (profile.getOutputFileSetting().isAddComment()) {
- if (!commentFile.isFile()) {
- throw new IOException("入力コメントファイルが存在しません:" + commentFile.getPath());
- }
- } else {
- commentFile = null;
- }
-
- /*ビデオ名の確定*/
- final boolean isNotLow = (vf == null) ? true : (vf.getStatus() != Status.GET_LOW);
- File convertedVideoFile = getOutputFileName(vi.getTitleInWatchPage(), isNotLow);
-
return new DownloadResult(true);
+
// TODO FFMPEG 実行開始は別タスクとして実装する.
+// if (!profile.getOutputFileSetting().isConvert()) {
+// publish(new DownloadProgress("動画・コメントを保存し、変換は行いませんでした。"));
+// return new DownloadResult(true);
+// }
+//
+// if (!videoFile.isFile()) {
+// throw new IOException("入力動画ファイルが存在しません:" + videoFile.getPath());
+// }
+//
+// if (profile.getOutputFileSetting().isAddComment()) {
+// if (!commentFile.isFile()) {
+// throw new IOException("入力コメントファイルが存在しません:" + commentFile.getPath());
+// }
+// } else {
+// commentFile = null;
+// }
+//
+// /*ビデオ名の確定*/
+// final boolean isNotLow = (vf == null) ? true : (vf.getStatus() != Status.GET_LOW);
+// File convertedVideoFile = getOutputFileName(vi.getTitleInWatchPage(), isNotLow);
+//
+
// boolean res = new FfmpegCommand(getListener(), getStopFlag(), commentFile, videoFile,
// convertedVideoFile, profile.getFfmpeg(), profile.getGeneralSetting()).execute();
// return res;
}
- /** @return 何か実行すべき処理があればtrue. */
- private static boolean shouldRun(Profile profile) {
- return profile.getOutputFileSetting().isConvert() || needsDownload(profile);
- }
-
/** @return 何かダウンロードするものがあればtrue. */
- private static boolean needsDownload(Profile profile) {
+ private static boolean needsDownload(DownloadProfile profile) {
return (profile.getVideoSetting().isDownload() || profile.getCommentSetting().isDownload());
}
return profile.getCommentSetting().getBackLogPoint() >= 0L;
}
- /**
- * 出力ファイルの保存先を確定します.
- * @param title 動画タイトル.
- * @param isNotLow 入力動画ファイルがlowでないかどうか.
- * @return 出力ファイルの保存先.
- */
- private File getOutputFileName(String title, boolean isNotLow) {
- final OutputProfile prof = profile.getOutputFileSetting();
- final GeneralProfile gene = profile.getGeneralSetting();
- final File dir = prof.getDir();
- 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(videoId, isNotLow);
- return new File(dir, name);
- }
-
private void checkStop() throws InterruptedException {
if (Thread.interrupted()) {
throw new InterruptedException("中止要求を受け付けました");
import saccubus.worker.profile.GeneralProfile;
import saccubus.worker.profile.LoginProfile;
import saccubus.worker.profile.OutputProfile;
-import saccubus.worker.profile.Profile;
+import saccubus.worker.profile.DownloadProfile;
import saccubus.worker.profile.ProxyProfile;
import saccubus.worker.profile.VideoProfile;
});
}
- private static class MyProfile implements Profile{
+ private static class MyProfile implements DownloadProfile{
@Override
public LoginProfile getLoginInfo() {
};
}
- @Override
- public OutputProfile getOutputFileSetting() {
- return new OutputProfile() {
-
- @Override
- public boolean isConvert() {
- return false;
- }
-
- @Override
- public boolean isAddComment() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public File getDir() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String getFileName() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- };
- }
+// @Override
+// public OutputProfile getOutputFileSetting() {
+// return new OutputProfile() {
+//
+// @Override
+// public boolean isConvert() {
+// return false;
+// }
+//
+// @Override
+// public boolean isAddComment() {
+// throw new UnsupportedOperationException("Not supported yet.");
+// }
+//
+// @Override
+// public File getDir() {
+// throw new UnsupportedOperationException("Not supported yet.");
+// }
+//
+// @Override
+// public String getFileName() {
+// throw new UnsupportedOperationException("Not supported yet.");
+// }
+// };
+// }
@Override
public GeneralProfile getGeneralSetting() {