public File get(File file, TextProgressListener listener) throws IOException {
String com = Integer.toString(backComment);
if (this.autoCommentNum) {
- com = getClient().getBackCommentFromLength(getVideoInfo(), com);
+ com = getBackCommentFromLength(getVideoInfo(), com);
}
File res = getClient().getComment(getVideoInfo(), file, listener, com);
}
return res;
}
+
+ private String getBackCommentFromLength(VideoInfo vi, String def) {
+ final int videoLength = vi.getVideoLength();
+ if (videoLength < 0) {
+ return def;
+ } else if (videoLength >= 0 && videoLength < 60) {
+ return "100";
+ } else if (videoLength >= 60 && videoLength < 300) {
+ return "250";
+ } else if (videoLength >= 300 && videoLength < 600) {
+ return "500";
+ } else {
+ return "1000";
+ }
+ }
}
import java.io.IOException;
/**
- *
+ * いんきゅばすがニコニコ動画にアクセスするためのクラスが実装すべきインタフェース.
+ * ログイン処理はコンストラクタ内で実行しておき、各メソッドは同一セッションで実行される必要があります.
* @author yuki
*/
public interface NicoClient {
- String getBackCommentFromLength(VideoInfo videoInfo, String com);
-
- File getComment(VideoInfo videoInfo, File file, TextProgressListener listener, String com);
+ /** @return ログインが正常に完了していればtrue. */
+ boolean isLoggedIn();
- File getTcomment(VideoInfo videoInfo, File file, TextProgressListener listener);
+ VideoInfo getVideoInfo(String videoId, String time) throws IOException;
File getVideo(VideoInfo videoInfo, File file, TextProgressListener listener);
- boolean isLoggedIn();
-
- VideoInfo getVideoInfo(String tag, String time) throws IOException;
+ File getComment(VideoInfo videoInfo, File file, TextProgressListener listener, String com);
+ File getTcomment(VideoInfo videoInfo, File file, TextProgressListener listener);
}
}
@Override
- public String getBackCommentFromLength(VideoInfo vi, String def) {
- final int videoLength = vi.getVideoLength();
- if (videoLength < 0) {
- return def;
- } else if (videoLength >= 0 && videoLength < 60) {
- return "100";
- } else if (videoLength >= 60 && videoLength < 300) {
- return "250";
- } else if (videoLength >= 300 && videoLength < 600) {
- return "500";
- } else {
- return "1000";
- }
- }
-
- @Override
public File getComment(VideoInfo vi, final File file, final TextProgressListener status, String back_comment) {
return downloadComment(back_comment, file, vi, status, false);
}