OSDN Git Service

コメント量を減らすパラメータを渡す処理実装
[coroid/inqubus.git] / frontend / src / saccubus / converter / filegetter / CommentFileWebGetter.java
1 /*
2  * To change this template, choose Tools | Templates
3  * and open the template in the editor.
4  */
5 package saccubus.converter.filegetter;
6
7 import java.io.File;
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;
13
14 /**
15  *
16  * @author yuki
17  */
18 public class CommentFileWebGetter extends TcommFileWebGetter {
19
20     private final boolean autoCommentNum;
21     private final int backComment;
22     private final boolean reduceComment;
23     private final CommentInfo commentInfo;
24
25     CommentFileWebGetter(NicoClient client, VideoInfo vi, CommentInfo ci, boolean autoCommentNum, int backComment, boolean reduceComment) {
26         super(client, vi);
27         this.autoCommentNum = autoCommentNum;
28         this.backComment = backComment;
29         this.reduceComment = reduceComment;
30         this.commentInfo = ci;
31     }
32
33     @Override
34     public File get(File file, TextProgressListener listener) throws IOException {
35         int com;
36         if (this.autoCommentNum) {
37             com = getVideoInfo().getBackCommentFromLength();
38         } else {
39             com = backComment;
40         }
41
42         File res = getClient().getComment(getVideoInfo(), getCommentInfo(), file, listener, com, reduceComment);
43         if (res == null) {
44             throw new IOException("コメントファイルのダウンロードに失敗しました。");
45         }
46         return res;
47     }
48
49     private CommentInfo getCommentInfo() {
50         return commentInfo;
51     }
52 }