import nicobrowser.entity.NicoContent.Status;
import org.apache.http.HttpException;
import saccubus.converter.profile.CommentProfile;
-import saccubus.converter.profile.FfmpegProfile;
import saccubus.converter.profile.GeneralProfile;
import saccubus.converter.profile.OutputProfile;
import saccubus.converter.profile.Profile;
private static final Logger logger = Logger.getLogger(Download.class.getName());
private final Profile profile;
- private final String movieId;
+ private final String videoId;
/**
* コンバータを構築します.
- * @param id 対象となる動画のID.
+ * @param videoId 対象となる動画のID.
* @param time
* @param profile
* @param listener
* @param flag
*/
- public Download(String id, Profile profile) {
- this.movieId = id;
+ public Download(Profile profile, String videoId) {
+ this.videoId = videoId;
this.profile = profile;
}
return new DownloadResult(true);
}
- validSetting();
-
- // TODO ログインしないで良い場合もある.
publish(new DownloadProgress("ログイン中"));
-
-
NicoHttpClient client = null;
nicobrowser.VideoInfo vi = null;
NamePattern videoNamePattern = null;
WayBackInfo wbi = null;
if (needsLogin()) {
client = createClientAndLogin();
- vi = client.getVideoInfo(movieId);
+ vi = client.getVideoInfo(videoId);
final String name = profile.getVideoSetting().getFileName();
final String replaceFrom = profile.getGeneralSetting().getReplaceFrom();
final NamePattern pattern = new NamePattern(prof.getFileName(), gene.getReplaceFrom(), gene.getReplaceTo(),
vi.getTitleInWatchPage());
// TODO コメントファイルに{low}は使えないことをどこかに書くべきか
- final String name = pattern.createFileName(movieId, true);
+ final String name = pattern.createFileName(videoId, true);
final File file = new File(profile.getCommentSetting().getDir(), name);
commentFile = client.getCommentFile(vi, file.getPath(), wbi, profile.getCommentSetting().
return (profile.getVideoSetting().isDownload() || profile.getCommentSetting().isDownload());
}
+ // TODO どこかに処理を移す必要がある.
/**
* (ネットワーク設定以外の)設定を検証する.
* @throws IllegalArgumentException 設定に不備がある場合.
*/
- private void validSetting() {
- if (profile.getOutputFileSetting().isConvert()) {
- File a = profile.getFfmpeg().getFfmpeg();
- if (!a.canRead()) {
- throw new IllegalArgumentException("FFmpegが見つかりません。");
- }
- if (profile.getFfmpeg().getVhook().getPath().indexOf(' ') >= 0) {
- throw new IllegalArgumentException("すいません。現在vhookライブラリには半角空白は使えません。");
- }
- a = profile.getFfmpeg().getVhook();
- if (!a.canRead()) {
- throw new IllegalArgumentException("Vhookライブラリが見つかりません。");
- }
- a = profile.getFfmpeg().getFont();
- if (!a.canRead()) {
- throw new IllegalArgumentException("フォントが見つかりません。");
- }
- }
- }
+// private void validSetting() {
+// if (profile.getOutputFileSetting().isConvert()) {
+// File a = profile.getFfmpeg().getFfmpeg();
+// if (!a.canRead()) {
+// throw new IllegalArgumentException("FFmpegが見つかりません。");
+// }
+// if (profile.getFfmpeg().getVhook().getPath().indexOf(' ') >= 0) {
+// throw new IllegalArgumentException("すいません。現在vhookライブラリには半角空白は使えません。");
+// }
+// a = profile.getFfmpeg().getVhook();
+// if (!a.canRead()) {
+// throw new IllegalArgumentException("Vhookライブラリが見つかりません。");
+// }
+// a = profile.getFfmpeg().getFont();
+// if (!a.canRead()) {
+// throw new IllegalArgumentException("フォントが見つかりません。");
+// }
+// }
+// }
/**
* HttpClientを生成し, ニコニコ動画サーバへログインします.
final String replaceFrom = gene.getReplaceFrom();
final String replaceTo = gene.getReplaceTo();
final NamePattern pattern = new NamePattern(prof.getFileName(), replaceFrom, replaceTo, title);
- final String name = pattern.createFileName(movieId, isNotLow);
+ final String name = pattern.createFileName(videoId, isNotLow);
return new File(dir, name);
}
private final File videoFile;
private final File convertedVideoFile;
private final ConvertProfile ffmpeg;
- private final Profile profile;
- Ffmpeg(File commentFile, File videoFile, File convertedVideoFile, ConvertProfile ffmpeg,
- GeneralProfile general, Profile profile) throws IOException {
+ Ffmpeg(File commentFile, File videoFile, File convertedVideoFile, ConvertProfile ffmpeg) throws IOException {
this.commentFile = commentFile;
this.videoFile = videoFile;
this.convertedVideoFile = convertedVideoFile;
this.ffmpeg = ffmpeg;
- this.profile = profile;
- File tmpDir = general.getTempDir();
+ File tmpDir = ffmpeg.getTempDir();
commentMiddleFile = File.createTempFile("vhk", ".tmp", tmpDir);
tcommMiddleFile = File.createTempFile("tcom", ".tmp", tmpDir);
TMP_CWS = File.createTempFile("cws", ".swf", tmpDir);
}
private FfmpegResult exec() throws InterruptedException, IOException {
- final FfmpegProfile ov = profile.getFfmpeg().getFfmpegOption();
final HideCondition ngSetting = getFfmpeg().getNgSetting();
if (commentFile != null) {
publish(new FfmpegProgress("コメントの中間ファイルへの変換中"));