package yukihane.inqubus.saccubus.prompt;
-import java.io.File;
import java.io.IOException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import org.apache.commons.cli.BasicParser;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.Options;
-import saccubus.FfmpegOption;
import saccubus.util.WayBackTimeParser;
+import saccubus.worker.impl.convert.Convert;
+import saccubus.worker.impl.convert.ConvertResult;
import saccubus.worker.impl.download.Download;
import saccubus.worker.impl.download.DownloadResult;
+import saccubus.worker.profile.ConvertProfile;
import saccubus.worker.profile.DownloadProfile;
/**
*/
public class Prompt {
- public static void main(String[] args) throws Exception {
- // 第1引数がメールアドレスと思しき時は昔の引数であるとみなしてパース、実行する.
- if (args.length > 0 && args[0].contains("@")) {
- doWithOldArguments(args);
- return;
- }
-
- new Prompt().execute(args);
- }
-
- public void execute(String[] args) throws IOException {
- throw new UnsupportedOperationException();
-// Options options = createOptions(args);
-// Profile profile;
-// try {
-// CommandLineParser parser = new BasicParser();
-// CommandLine cmd = parser.parse(options, args);
-// profile = createExecuteOption(cmd);
-// } catch (Exception e) {
-// HelpFormatter hf = new HelpFormatter();
-// hf.printHelp("java -jar Saccubus.jar [opts]", options);
-// System.out.flush();
-// throw new IOException(e);
-// }
-//
-// Download conv = new Download(profile, "dummy0");
-// ExecutorService es = Executors.newSingleThreadExecutor();
-// final Future<DownloadResult> future = es.submit(conv);
-// try {
-// boolean res = future.get().getResultValue();
-// if (!res) {
-// throw new IOException("ffmpeg変換処理が正常に終了しませんでした。");
-// }
-// } catch (Exception ex) {
-// throw new IOException("取得失敗", ex);
-// }
-// System.out.println("Finished.");
- }
-
- private Options createOptions(String[] args) {
- Options options = new Options();
-// Option id = OptionBuilder.withArgName("mail").hasArg().withDescription("ニコニコ動画ログインID(メールアドレス)").create("id");
-// Option password = OptionBuilder.withArgName("password").hasArg().withDescription("ニコニコ動画ログインパスワード").
-// create("password");
-// Option video = OptionBuilder.withArgName("id").hasArg().withDescription("ニコニコ動画ビデオID").create("video");
- Option videoFile = OptionBuilder.withArgName("file").hasArg().withDescription("動画ファイル").create("file_video");
- Option commentFile = OptionBuilder.withArgName("file").hasArg().withDescription("コメントファイル").
- create("file_comment");
- Option tcommentFile = OptionBuilder.withArgName("file").hasArg().withDescription("投稿者コメントファイル").
- create("file_tcomment");
- Option outputFile = OptionBuilder.withArgName("file").hasArg().withDescription("出力ファイル").create("file_output");
- Option ffmpeg = OptionBuilder.withArgName("option").hasArg().withDescription("ffmpeg変換オプション").create("ffmpeg");
-// options.addOption(id);
-// options.addOption(password);
-// options.addOption(video);
- options.addOption(videoFile);
- options.addOption(commentFile);
- options.addOption(tcommentFile);
- options.addOption(outputFile);
- options.addOption(ffmpeg);
- return options;
- }
-
-// private Profile createExecuteOption(CommandLine cmd) throws IOException {
-// final String mail = "dmy";
-// final String pass = "dmy";
-// final String video = cmd.getOptionValue("file_video");
-// final String comm = cmd.getOptionValue("file_comment");
-// final String tcomm = cmd.getOptionValue("file_tcomment");
-// final String output = cmd.getOptionValue("file_output");
-// final String ff = cmd.getOptionValue("ffmpeg");
-//
-// // TODO 後で実装
-//// SProperties setting = SProperties.loadSetting(mail, pass);
-//// Profile p = setting.toProfile();
-// Profile p = null;
-// GeneralSetting general = p.getGeneralSetting();
-// LoginInfo loginInfo = p.getLoginInfo();
-//// InputFileSetting videoSetting = p.getVideoSetting();
-//// InputFileSetting commentSetting = p.getCommentSetting();
-// CommentGetInfo commentGetInfo = p.getCommentGetInfo();
-//// InputFileSetting tcommentSetting = p.getTcommentSetting();
-//// OutputFileSetting outputFileSetting = p.getOutputFileSetting();
-// Ffmpeg ffmpeg = p.getFfmpeg();
-//
-// FfmpegOption newFfmpegOption = new FfmpegOption(ffmpeg.getFfmpegOption().getExtOption(), "", "", ff, "", false,
-// "", "", false);
-// InputFileSetting newVideoSetting = new InputFileSetting(new SFile(true, new File(video)), false, false, commentGetInfo, -1);
-// InputFileSetting newCommentSetting = new InputFileSetting(new SFile(true, new File(comm)), false, false, commentGetInfo, -1);
-// InputFileSetting newTcommentSetting = new InputFileSetting(new SFile(true, new File(tcomm)), false, false, commentGetInfo, -1);
-// OutputFileSetting newOutputFileSetting = new OutputFileSetting(new SFile(true, new File(output)), true, false,
-// true, true);
-// Ffmpeg newFfmpeg = new Ffmpeg(ffmpeg.getFfmpeg(), ffmpeg.getVhook(), newFfmpegOption, ffmpeg.isVhookDisabled(), ffmpeg.
-// getMaxNumOfComment(), ffmpeg.getFont(), ffmpeg.getFontIndex(), ffmpeg.getShadowIndex(), ffmpeg.
-// isShowConverting(), ffmpeg.isSelfAdjustFontSize(), ffmpeg.isCommentOpaque(), ffmpeg.getNgSetting());
-//
-// p = new Profile(general, loginInfo, newVideoSetting, newCommentSetting, commentGetInfo, newTcommentSetting,
-// newOutputFileSetting, newFfmpeg);
-//
-// return p;
-// }
-
- /**
- * 昔の引数形式でプログラムを実行する.
- */
- private static void doWithOldArguments(String[] args) throws Exception {
- String mail = args[0];
- String pass = args[1];
- String tag = args[2];
- long time = args.length < 4 ? -1L : WayBackTimeParser.parse(args[3]);
-
- final DownloadProfile profile = new DownloadProfileImpl(mail, pass, time);
- final Download download = new Download(profile, tag);
+ public void main(String[] args) throws IOException, Exception {
+ final String mail = args[0];
+ final String pass = args[1];
+ final String tag = args[2];
+ final long time = args.length < 4 ? -1L : WayBackTimeParser.parse(args[3]);
+ final DownloadProfile downloadSetting = new DownloadProfileImpl(mail, pass, time);
+ final Download down = new Download(downloadSetting, tag);
System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
System.out.println("Saccubus on CUI");
System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
System.out.println("VideoID: " + tag);
System.out.println("WaybackTime: " + time);
System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
- download.call();
- // TODO 変換処理が必要
+ final DownloadResult dRes = down.call();
+
+ final ConvertProfile setting = new ConvertProfileImpl(tag, "");
+ final Convert conv = new Convert(setting, dRes.getDownloadVideo(), dRes.getDownloadComment());
+ final ConvertResult cRes = conv.call();
+
System.out.println("Finished.");
}
}