out.write(buffer, 0, i);
downloadSize += i;
listener.progress(fileSize, downloadSize);
- if(listener.getCancel()){
+ if (listener.getCancel()) {
return new GetFlvResult(null, Status.GET_INFO, userName);
}
}
return getFlvFile(vi, vi.getRealVideoId(), Status.GET_INFO, true, ProgressListener.EMPTY_LISTENER);
}
- public File getCommentFile(VideoInfo vi, String fileName) throws Exception {
- return downloadComment(vi, fileName, false);
+ public File getCommentFile(VideoInfo vi, String fileName, WayBackInfo wayback) throws Exception {
+ return downloadComment(vi, fileName, false, wayback);
}
public File getTCommentFile(VideoInfo vi, String fileName) throws Exception {
- return downloadComment(vi, fileName, true);
+ return downloadComment(vi, fileName, true, null);
}
- private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm) throws Exception {
+ private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm, WayBackInfo wayback) throws Exception {
HttpResponse response = null;
BufferedOutputStream bos = null;
try {
final HttpPost post = new HttpPost(vi.getMessageUrl().toString());
- final String param = createCommendDownloadParameter(vi, isTcomm);
+ final String param = createCommendDownloadParameter(vi, isTcomm, wayback);
final StringEntity se = new StringEntity(param);
post.setEntity(se);
response = http.execute(post);
}
}
- private String createCommendDownloadParameter(VideoInfo vi, boolean isTcomm) {
+ private String createCommendDownloadParameter(VideoInfo vi, boolean isTcomm, WayBackInfo wayback) {
final String tcommStr = (isTcomm) ? "fork=\"1\" " : "";
+ final String wayBackStr = (wayback != null) ? "when=" + "\"" + wayback.getTime() + "\"" + " waybackkey=" + "\""
+ + wayback.getKey() + " " : "";
StringBuilder builder = new StringBuilder();
Set<String> keySet = vi.getKeyMap().keySet();
for (String key : keySet) {
--- /dev/null
+package nicobrowser;
+
+/**
+ * 過去ログを取得するための情報.
+ * @author yuki
+ */
+public class WayBackInfo {
+
+ private final String key;
+ private final String time;
+
+ public WayBackInfo(String key, String time) {
+ if (key == null || time == null) {
+ throw new IllegalArgumentException(" key: " + key + ", time: " + time);
+ }
+
+ this.key = key;
+ this.time = time;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getTime() {
+ return time;
+ }
+}
assertSame(0, list.size());
}
-//
+//
public void loadMyListDaily() throws URISyntaxException, HttpException, InterruptedException {
System.out.println("loadMyListDaily");
List<NicoContent> list = instance.loadMyListDaily();
instance.login(OK_MAIL, OK_PASS);
VideoInfo vi = instance.getVideoInfo(NORMAL_VIDEO);
- instance.getCommentFile(vi, comm);
+ instance.getCommentFile(vi, comm, null);
instance.getTCommentFile(vi, tcomm);
assertTrue(commFile.exists());
instance.login(OK_MAIL, OK_PASS);
VideoInfo vi = instance.getVideoInfo(OFFICIAL_VIDEO);
- instance.getCommentFile(vi, comm);
+ instance.getCommentFile(vi, comm, null);
instance.getTCommentFile(vi, tcomm);
assertTrue(commFile.exists());