return getFlvFile(vi, vi.getRealVideoId(), Status.GET_INFO, true, ProgressListener.EMPTY_LISTENER);
}
- public File getCommentFile(VideoInfo vi, String fileName, WayBackInfo wayback) throws Exception {
- return downloadComment(vi, fileName, false, wayback);
+ public File getCommentFile(VideoInfo vi, String fileName, WayBackInfo wayback, int commentNum) throws Exception {
+ return downloadComment(vi, fileName, false, wayback, Integer.valueOf(commentNum));
+ }
+
+ public File getCommentFile(VideoInfo vi, String fileName) throws Exception {
+ return downloadComment(vi, fileName, false, null, null);
}
public File getTCommentFile(VideoInfo vi, String fileName) throws Exception {
- return downloadComment(vi, fileName, true, null, true);
+ return downloadComment(vi, fileName, true, null, Integer.valueOf(1000), true);
}
- private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm, WayBackInfo wayback) throws Exception {
- return downloadComment(vi, fileName, isTcomm, wayback, false);
+ private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm, WayBackInfo wayback, Integer commentNum)
+ throws Exception {
+ return downloadComment(vi, fileName, isTcomm, wayback, commentNum, false);
}
- private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm, WayBackInfo wayback, boolean oldVersion)
+ private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm, WayBackInfo wayback, Integer commentNum,
+ boolean oldVersion)
throws Exception {
HttpResponse response = null;
BufferedOutputStream bos = null;
final HttpPost post = new HttpPost(vi.getMessageUrl().toString());
final String param;
if (oldVersion || isTcomm) {
- param = createCommendDownloadParameter20101222(vi, isTcomm, wayback);
+ param = createCommendDownloadParameter20101222(vi, isTcomm, wayback, commentNum);
} else {
- param = createCommendDownloadParameter(vi, wayback);
+ param = createCommendDownloadParameter(vi, wayback, commentNum);
}
final StringEntity se = new StringEntity(param);
post.setEntity(se);
}
}
- private String createCommendDownloadParameter(VideoInfo vi, WayBackInfo wayback) {
+ private String createCommendDownloadParameter(VideoInfo vi, WayBackInfo wayback, Integer commentNum) {
+ // TODO 通常 wayback はnullのはずだが…要確認
final String quote = "\"";
final Map<String, String> th = new HashMap<String, String>();
th.put("thread", vi.getThreadId());
leaf.put("user_id", vi.getUserId());
final int length = (int) Math.ceil(vi.getVideoLength() / 60.0);
- final String element = "0-" + length + ":100," + vi.getResFrom();
+ final int resFrom = (commentNum != null) ? commentNum.intValue() : vi.getResFrom();
+ final String element = "0-" + length + ":100," + resFrom;
final StringBuilder str = new StringBuilder();
str.append("<packet>");
* 2010/12/22 までのコメント表示仕様に基づいた取得パラメータ生成.
* 「コメントの量を減らす」にチェックを入れた場合は現在でもこれが用いられているはず.
*/
- private String createCommendDownloadParameter20101222(VideoInfo vi, boolean isTcomm, WayBackInfo wayback) {
+ private String createCommendDownloadParameter20101222(VideoInfo vi, boolean isTcomm, WayBackInfo wayback,
+ Integer commentNum) {
+ final int resFrom = (commentNum == null || commentNum <= 0) ? vi.getResFrom() : commentNum.intValue();
final String tcommStr = (isTcomm) ? "fork=\"1\" " : "";
- // TODO wayBackStr 使用するのを忘れている
final String wayBackStr = (wayback != null) ? "when=" + "\"" + wayback.getTime() + "\"" + " waybackkey=" + "\""
+ wayback.getKey() + " " : "";
StringBuilder builder = new StringBuilder();
}
final String officialOption = builder.toString();
- return "<thread " + VideoInfo.KEY_USER_ID + "=\"" + vi.getUserId() + "\" res_from=\"" + (-1 * vi.getResFrom())
- + "\" version=\"20061206\" thread=\"" + vi.getThreadId() + "\" " + tcommStr + officialOption + "/>";
+ return "<thread " + VideoInfo.KEY_USER_ID + "=\"" + vi.getUserId() + "\" res_from=\"" + (-1 * resFrom)
+ + "\" version=\"20061206\" thread=\"" + vi.getThreadId() + "\" " + wayBackStr + tcommStr
+ + officialOption + "/>";
}
/**