return getFlvFile(vi, vi.getRealVideoId(), Status.GET_INFO, true, ProgressListener.EMPTY_LISTENER);
}
- 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, WayBackInfo wayback, int commentNum, boolean oldVersion)
+ throws Exception {
+ return downloadComment(vi, fileName, false, wayback, Integer.valueOf(commentNum), oldVersion);
}
public File getCommentFile(VideoInfo vi, String fileName) throws Exception {
- return downloadComment(vi, fileName, false, null, null);
+ return downloadComment(vi, fileName, false, null, null, false);
}
public File getTCommentFile(VideoInfo vi, String fileName) throws Exception {
return downloadComment(vi, fileName, true, null, Integer.valueOf(1000), true);
}
- 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, Integer commentNum,
boolean oldVersion)
throws Exception {
*/
private String createCommentDownloadParameter20101222(VideoInfo vi, boolean isTcomm, WayBackInfo wayback,
Integer commentNum) {
+ final Map<String, String> params = new HashMap<String, String>();
+
+ params.put(VideoInfo.KEY_USER_ID, vi.getUserId());
+ params.put("thread", vi.getThreadId());
+ params.put("version", "20061206");
+
final int resFrom = (commentNum == null || commentNum <= 0) ? vi.getResFrom() : commentNum.intValue();
- 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) {
- builder.append(key).append("=\"").append(vi.getKeyMap().get(key)).append("\" ");
- }
- final String officialOption = builder.toString();
-
- return "<thread " + VideoInfo.KEY_USER_ID + "=\"" + vi.getUserId() + "\" res_from=\"" + (-1 * resFrom)
- + "\" version=\"20061206\" thread=\"" + vi.getThreadId() + "\" " + wayBackStr + tcommStr
- + officialOption + "/>";
+ params.put("res_from", "-" + Integer.toString(resFrom));
+
+ if (isTcomm) {
+ params.put("fork", "1");
+ }
+
+ if (wayback != null) {
+ params.put("waybackkey", wayback.getKey());
+ params.put("when", Long.toString(wayback.getTime()));
+ }
+
+ final StringBuilder str = new StringBuilder();
+ str.append("<thread");
+
+ addMapToAttr(str, vi.getKeyMap());
+ addMapToAttr(str, params);
+
+ str.append("/>");
+
+ return str.toString();
}
/**