import java.io.IOException;
import java.text.Normalizer;
+import org.apache.commons.lang.StringUtils;
import saccubus.ConvertStopFlag;
+import saccubus.net.CommentInfo;
import saccubus.net.NicoClient;
import saccubus.net.VideoInfo;
+import saccubus.util.WayBackTimeParser;
+import yukihane.inqubus.saccubus_adapter.NicoBrowserAdapter;
import yukihane.saccubus.converter.profile.Proxy;
-import yukihane.saccubus.converter.profile.LoginInfo;
+import yukihane.saccubus.converter.profile.LoinProfile;
/**
* 動画ファイル, コメントファイルなど必要なファイルのうち, 1つでもダウンロード処理を必要とする場合のインスタンス化クラス.
private final NicoClient client;
private final VideoInfo videoInfo;
+ private final CommentInfo commentInfo;
WebFileInstanciator(
ConvertStopFlag stopFlag,
InstanciationType videoType,
CommentInstanciationType commentType,
InstanciationType tcommType,
- LoginInfo li,
+ LoinProfile li,
Proxy proxy,
String tag,
String time) throws IOException {
host = null;
port = -1;
}
- client = new NicoClient(li.getMail(), li.getPass(), stopFlag, host, port);
+ client = new NicoBrowserAdapter(li.getMail(), li.getPass(), stopFlag, host, port) {
+ };
if (!client.isLoggedIn()) {
throw new IOException("ログインに失敗");
}
try {
- videoInfo = client.getVideoInfo(tag, time);
+ videoInfo = client.getVideoInfo(tag);
+ if (StringUtils.isNotBlank(time)) {
+ System.out.print("Setting wayback time...");
+ final long waybacktime = WayBackTimeParser.parse(time);
+ String waybackkey = client.getWayBackKey(videoInfo);
+ commentInfo = new CommentInfo(waybackkey, waybacktime);
+ } else {
+ commentInfo = null;
+ }
+
} catch (IOException ex) {
- throw new IOException(tag + "の情報の取得に失敗", ex);
+ final String text = tag + "の情報の取得に失敗";
+ final String cause = (ex.getMessage() != null) ? "(" + ex.getMessage() + ")" : "";
+
+ throw new IOException(text + cause, ex);
}
- if (videoType.isDoanload()) {
+ if (videoType.isDownload()) {
setVideoFileGetter(new VideoFileWebGetter(client, videoInfo));
}
- if (commentType.isDoanload()) {
- setCommentFileGetter(new CommentFileWebGetter(client, videoInfo, commentType.isAutoCommentNum(),
- commentType.getBackComment()));
+ if (commentType.isDownload()) {
+ setCommentFileGetter(new CommentFileWebGetter(client, videoInfo, commentInfo, commentType.isAutoCommentNum(),
+ commentType.getBackComment(), commentType.isReduceComment()));
}
- if (tcommType.isDoanload()) {
+ if (tcommType.isDownload()) {
setTcommFileGetter(new TcommFileWebGetter(client, videoInfo));
}
}