2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
5 package saccubus.converter.filegetter;
8 import java.io.IOException;
9 import saccubus.net.CommentInfo;
10 import saccubus.net.NicoClient;
11 import saccubus.net.TextProgressListener;
12 import saccubus.net.VideoInfo;
18 public class CommentFileWebGetter extends TcommFileWebGetter {
20 private final boolean autoCommentNum;
21 private final int backComment;
22 private final CommentInfo commentInfo;
24 CommentFileWebGetter(NicoClient client, VideoInfo vi, CommentInfo ci, boolean autoCommentNum, int backComment) {
26 this.autoCommentNum = autoCommentNum;
27 this.backComment = backComment;
28 this.commentInfo = ci;
32 public File get(File file, TextProgressListener listener) throws IOException {
33 String com = Integer.toString(backComment);
34 if (this.autoCommentNum) {
35 com = getBackCommentFromLength(getVideoInfo(), com);
38 File res = getClient().getComment(getVideoInfo(), getCommentInfo(), file, listener, com);
40 throw new IOException("コメントファイルのダウンロードに失敗しました。");
45 private String getBackCommentFromLength(VideoInfo vi, String def) {
46 final int videoLength = vi.getVideoLength();
47 if (videoLength < 0) {
49 } else if (videoLength >= 0 && videoLength < 60) {
51 } else if (videoLength >= 60 && videoLength < 300) {
53 } else if (videoLength >= 300 && videoLength < 600) {
60 private CommentInfo getCommentInfo() {