import nicobrowser.util.Util;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.http.Header;
}
}
+ private enum ThreadType {
+
+ MAIN, OPTIONAL;
+ }
+
/**
* 2011/2/3 以降のコメント表示仕様に基づいた取得パラメータ生成.
* @param vi ビデオ情報.
* @return 生成されたパラメータ.
*/
private String createCommentDownloadParameter(VideoInfo vi, WayBackInfo wayback, int commentNum) {
+ final String mainParam = createCommentDownloadParameter(ThreadType.MAIN, vi, wayback, commentNum);
+ final String optionParam;
+ if (StringUtils.isNotEmpty(vi.getOptionalThreadId())) {
+ optionParam = createCommentDownloadParameter(ThreadType.OPTIONAL, vi, wayback, commentNum);
+ } else {
+ optionParam = "";
+ }
+ return mainParam + optionParam;
+ }
+
+ private String createCommentDownloadParameter(ThreadType threadType, VideoInfo vi, WayBackInfo wayback,
+ int commentNum) {
final Map<String, String> threadKey = vi.getKeyMap();
final Map<String, String> th = new HashMap<String, String>();
- th.put("thread", vi.getThreadId());
+ if (threadType != ThreadType.OPTIONAL) {
+ th.put("thread", vi.getThreadId());
+ } else {
+ th.put("thread", vi.getOptionalThreadId());
+ }
th.put("version", "20090904");
th.put("user_id", vi.getUserId());
if (wayback != null) {
*/
private String createCommentDownloadParameter20101222(VideoInfo vi, boolean isTcomm, WayBackInfo wayback,
int commentNum) {
+ final String mainParam = createCommentDownloadParameter20101222(ThreadType.MAIN, vi, isTcomm, wayback,
+ commentNum);
+ final String optionParam;
+ if (StringUtils.isNotEmpty(vi.getOptionalThreadId())) {
+ optionParam = createCommentDownloadParameter20101222(ThreadType.OPTIONAL, vi, isTcomm, wayback, commentNum);
+ } else {
+ optionParam = "";
+ }
+ return mainParam + optionParam;
+ }
+
+ private String createCommentDownloadParameter20101222(ThreadType threadType, VideoInfo vi, boolean isTcomm,
+ WayBackInfo wayback, int commentNum) {
final Map<String, String> params = new HashMap<String, String>();
params.put(VideoInfo.KEY_USER_ID, vi.getUserId());
- params.put("thread", vi.getThreadId());
+ if (threadType != ThreadType.OPTIONAL) {
+ params.put("thread", vi.getThreadId());
+ } else {
+ params.put("thread", vi.getOptionalThreadId());
+ }
params.put("version", "20061206");
final int resFrom = (commentNum > 0) ? commentNum : vi.getResFrom();