import java.io.File;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.util.concurrent.Callable;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import nicobrowser.GetFlvResult;
+import nicobrowser.NamePattern;
+import nicobrowser.NicoHttpClient;
+import nicobrowser.ProgressListener;
+import nicobrowser.WayBackInfo;
+import nicobrowser.entity.NicoContent.Status;
import saccubus.ConvertStopFlag;
import saccubus.converter.filegetter.FileInstanciator;
+import saccubus.net.CommentInfo;
import saccubus.net.TextProgressListener;
+import yukihane.inqubus.saccubus_adapter.NicoBrowserAdapter;
+import yukihane.saccubus.converter.profile.CommentProfile;
import yukihane.saccubus.converter.profile.FfmpegOption;
+import yukihane.saccubus.converter.profile.LoinProfile;
import yukihane.saccubus.converter.profile.Profile;
+import yukihane.saccubus.converter.profile.ProxyProfile;
+import yukihane.saccubus.converter.profile.VideoProfile;
/**
* <p>タイトル: さきゅばす</p>
}
}
- private boolean runConvert() throws IOException, InterruptedException {
+ private boolean runConvert() throws IOException, InterruptedException, Exception {
if (!shouldRun(profile)) {
sendText("何もすることがありません");
return true;
validSetting();
final FfmpegOption ov = profile.getFfmpeg().getFfmpegOption();
+ // TODO ログインしないで良い場合もある.
sendText("ログイン中");
- final FileInstanciator fi = createInstanciator();
-
- stopFlagReturn();
+ final NicoHttpClient client = createClient(profile.getProxySetting());
+ final boolean hasLogin;
+ try {
+ hasLogin = client.login(profile.getLoginInfo().getMail(), profile.getLoginInfo().getPass());
+ if (!hasLogin) {
+ throw new IOException("login fail");
+ }
+ } catch (URISyntaxException ex) {
+ throw new IOException("login fail", ex);
+ }
+ final nicobrowser.VideoInfo vi = client.getVideoInfo(movieId);
- File commentFile = fi.getCommentFile(getListener());
+// final FileInstanciator fi = createInstanciator();
stopFlagReturn();
- File tcommFile = fi.getTcommFile(getListener());
+ WayBackInfo wbi = null;
+ if (profile.getCommentSetting().getBackLogPoint() >= 0L) {
+ final String key = client.getWayBackKey(vi);
+ wbi = new WayBackInfo(key, profile.getCommentSetting().getBackLogPoint());
+ }
+
+ File commentFile = client.getCommentFile(vi, profile.getCommentSetting().getFile().getPath(), wbi, profile.
+ getCommentSetting().getBackComment(), profile.getCommentSetting().isReduceComment());
stopFlagReturn();
+ // File tcommFile = fi.getTcommFile(getListener());
+ //
+ // stopFlagReturn();
+ // final File videoFile = getVideoFile(client, getListener(), profile.getVideoSetting());
+ GetFlvResult vf = client.getFlvFile(vi, profile.getVideoSetting().getDir(), new NamePattern("test", "_", "_",
+ "title"), Status.GET_INFO, true, new ProgressListener() {
+
+ @Override
+ public void progress(long fileSize, long downloadSize) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
- final File videoFile = fi.getVideoFile(getListener());
+ @Override
+ public boolean getCancel() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ });
+
+ final File videoFile = vf.getFile();
if (!profile.getOutputFileSetting().isConvert()) {
sendText("動画・コメントを保存し、変換は行いませんでした。");
commentFile = null;
}
- if (profile.getOutputFileSetting().isAddTcomment()) {
- if (!tcommFile.isFile()) {
- throw new IOException("入力投稿者コメントファイルが存在しません" + tcommFile.getPath());
- }
- } else {
- tcommFile = null;
- }
+// if (profile.getOutputFileSetting().isAddTcomment()) {
+// if (!tcommFile.isFile()) {
+// throw new IOException("入力投稿者コメントファイルが存在しません" + tcommFile.getPath());
+// }
+// } else {
+// tcommFile = null;
+// }
/*ビデオ名の確定*/
- File convertedVideoFile;
- if (!profile.getOutputFileSetting().getFile().isFile()) {
- String conv_name = fi.getVideoTitle();
- if (profile.getOutputFileSetting().isAppendPrefixVideoId()) {
- conv_name = getVideoIDWithBracket() + conv_name;
- }
- convertedVideoFile = new File(profile.getOutputFileSetting().getFile().getFile(),
- conv_name + ov.getExtOption());
- } else {
- String filename = profile.getOutputFileSetting().getFile().getFile().getPath();
- if (!filename.endsWith(ov.getExtOption())) {
- filename = filename.substring(0, filename.lastIndexOf('.')) + ov.getExtOption();
- convertedVideoFile = new File(filename);
- } else {
- convertedVideoFile = profile.getOutputFileSetting().getFile().getFile();
- }
- }
-
- boolean res = new FfmpegCommand(getListener(), getStopFlag(), commentFile, tcommFile, videoFile,
+ File convertedVideoFile = videoFile;
+// if (!profile.getOutputFileSetting().getFile().isFile()) {
+// String conv_name = fi.getVideoTitle();
+// if (profile.getOutputFileSetting().isAppendPrefixVideoId()) {
+// conv_name = getVideoIDWithBracket() + conv_name;
+// }
+// convertedVideoFile = new File(profile.getOutputFileSetting().getFile().getFile(),
+// conv_name + ov.getExtOption());
+// } else {
+// String filename = profile.getOutputFileSetting().getFile().getFile().getPath();
+// if (!filename.endsWith(ov.getExtOption())) {
+// filename = filename.substring(0, filename.lastIndexOf('.')) + ov.getExtOption();
+// convertedVideoFile = new File(filename);
+// } else {
+// convertedVideoFile = profile.getOutputFileSetting().getFile().getFile();
+// }
+// }
+
+ boolean res = new FfmpegCommand(getListener(), getStopFlag(), commentFile, videoFile,
convertedVideoFile, profile.getFfmpeg(), profile.getGeneralSetting()).execute();
return res;
}
- private FileInstanciator createInstanciator() throws IOException {
- FileInstanciator fi;
-
- FileInstanciator.InstanciationType videoType = new FileInstanciator.InstanciationType(profile.getVideoSetting());
-
- FileInstanciator.CommentInstanciationType commentType = new FileInstanciator.CommentInstanciationType(profile.
- getCommentSetting(), profile.getCommentSetting().isSelfAdjustCommentNum(), profile.getCommentSetting().
- getBackComment(), profile.getCommentSetting().isReduceComment());
-
- FileInstanciator.InstanciationType tcommType = new FileInstanciator.InstanciationType(
- profile.getCommentSetting());
-
- fi = FileInstanciator.create(getStopFlag(), videoType, commentType, tcommType, profile.getLoginInfo(), profile.
- getProxySetting(), movieId, profile.getCommentSetting().getBackLogPoint());
- return fi;
- }
+// private FileInstanciator createInstanciator() throws IOException {
+// FileInstanciator fi;
+//
+// FileInstanciator.InstanciationType videoType = new FileInstanciator.InstanciationType(profile.getVideoSetting());
+//
+// FileInstanciator.CommentInstanciationType commentType = new FileInstanciator.CommentInstanciationType(profile.
+// getCommentSetting(), profile.getCommentSetting().isSelfAdjustCommentNum(), profile.getCommentSetting().
+// getBackComment(), profile.getCommentSetting().isReduceComment());
+//
+// FileInstanciator.InstanciationType tcommType = new FileInstanciator.InstanciationType(
+// profile.getCommentSetting());
+//
+// fi = FileInstanciator.create(getStopFlag(), videoType, commentType, tcommType, profile.getLoginInfo(), profile.
+// getProxySetting(), movieId, profile.getCommentSetting().getBackLogPoint());
+// return fi;
+// }
/**
* (ネットワーク設定以外の)設定を検証する.
private static boolean needsDownload(Profile profile) {
return (profile.getVideoSetting().isDownload() || profile.getCommentSetting().isDownload());
}
+
+// private File getCommentFile(NicoBrowserAdapter client, VideoInfo vi, CommentProfile prof,
+// TextProgressListener listener) throws IOException {
+// if (prof.isDownload()) {
+// WayBackInfo wbi = null;
+// if (profile.getCommentSetting().getBackLogPoint() >= 0L) {
+// final String key = client.getWayBackKey(vi);
+// wbi = new WayBackInfo(key, profile.getCommentSetting().getBackLogPoint());
+// }
+//
+// return client.getCommentFile(nicoBrowserVi, prof.getFile().getPath(), wbi, prof.getBackComment(), prof.
+// isReduceComment());
+//
+//
+// } else {
+// }
+// }
+ private File getVideoFile(NicoBrowserAdapter client, TextProgressListener listener, VideoProfile videoSetting) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ private NicoHttpClient createClient(ProxyProfile proxy) {
+ if (proxy.use()) {
+ return new NicoHttpClient(proxy.getHost(), proxy.getPort());
+ } else {
+ return new NicoHttpClient();
+ }
+ }
}
private final File tcommMiddleFile;
private final File TMP_CWS;
private final File commentFile;
- private final File tcommFile;
private final File videoFile;
private final File convertedVideoFile;
private final FfmpegProfile ffmpeg;
- FfmpegCommand(TextProgressListener listener, ConvertStopFlag flag, File commentFile, File tcommFile,
+ FfmpegCommand(TextProgressListener listener, ConvertStopFlag flag, File commentFile,
File videoFile, File convertedVideoFile, FfmpegProfile ffmpeg, GeneralProfile general) throws IOException {
super(listener, flag);
this.commentFile = commentFile;
- this.tcommFile = tcommFile;
this.videoFile = videoFile;
this.convertedVideoFile = convertedVideoFile;
this.ffmpeg = ffmpeg;
}
}
stopFlagReturn();
- if (tcommFile != null) {
- sendText("投稿者コメントの中間ファイルへの変換中");
- boolean conv = ConvertToVideoHook.convert(tcommFile, tcommMiddleFile, ngSetting.getId(), ngSetting.getWord());
- if (!conv) {
- sendText("コメント変換に失敗。ファイル名に使用できない文字が含まれているか正規表現の間違い?");
- return false;
- }
- }
+// if (tcommFile != null) {
+// sendText("投稿者コメントの中間ファイルへの変換中");
+// boolean conv = ConvertToVideoHook.convert(tcommFile, tcommMiddleFile, ngSetting.getId(), ngSetting.getWord());
+// if (!conv) {
+// sendText("コメント変換に失敗。ファイル名に使用できない文字が含まれているか正規表現の間違い?");
+// return false;
+// }
+// }
stopFlagReturn();
sendText("動画の変換を開始");
int code;
if ((code = converting_video(videoFile, convertedVideoFile, (commentFile != null), commentMiddleFile.getPath(),
- (tcommFile
- != null), tcommMiddleFile.getPath(), getFfmpeg().getFfmpegOption())) == 0) {
+ false, tcommMiddleFile.getPath(), getFfmpeg().getFfmpegOption())) == 0) {
sendText("変換が正常に終了しました。");
return true;
} else {