* @author 未入力
* @version 1.0
*/
-public class Converter extends SwingWorker<ConvertResult, ConvertProgress> implements Callable<Boolean> {
+public class Download extends SwingWorker<DownloadResult, DownloadProgress> implements Callable<Boolean> {
- private static final Logger logger = Logger.getLogger(Converter.class.getName());
+ private static final Logger logger = Logger.getLogger(Download.class.getName());
private final Profile profile;
private final String movieId;
* @param listener
* @param flag
*/
- public Converter(String id, Profile profile) {
+ public Download(String id, Profile profile) {
this.movieId = id;
this.profile = profile;
}
@Override
public Boolean call() throws Exception {
try {
- final ConvertResult result = doInBackground();
+ final DownloadResult result = doInBackground();
return Boolean.valueOf(result.getResultValue());
} finally {
// TODO 何か処理が必要?
// }
// }
@Override
- protected ConvertResult doInBackground() throws Exception {
+ protected DownloadResult doInBackground() throws Exception {
if (!shouldRun(profile)) {
- publish(new ConvertProgress("何もすることがありません"));
- return new ConvertResult(true);
+ publish(new DownloadProgress("何もすることがありません"));
+ return new DownloadResult(true);
}
validSetting();
final FfmpegProfile ov = profile.getFfmpeg().getFfmpegOption();
// TODO ログインしないで良い場合もある.
- publish(new ConvertProgress("ログイン中"));
+ publish(new DownloadProgress("ログイン中"));
}
if (!profile.getOutputFileSetting().isConvert()) {
- publish(new ConvertProgress("動画・コメントを保存し、変換は行いませんでした。"));
- return new ConvertResult(true);
+ publish(new DownloadProgress("動画・コメントを保存し、変換は行いませんでした。"));
+ return new DownloadResult(true);
}
if (!videoFile.isFile()) {
final boolean isNotLow = (vf == null) ? true : (vf.getStatus() != Status.GET_LOW);
File convertedVideoFile = getOutputFileName(vi.getTitleInWatchPage(), isNotLow);
- return new ConvertResult(true);
+ return new DownloadResult(true);
// TODO FFMPEG 実行開始は別タスクとして実装する.
// boolean res = new FfmpegCommand(getListener(), getStopFlag(), commentFile, videoFile,
*
* @author yuki
*/
-public class FfmpegCommandProgress {
+public class DownloadProgress {
private final String message;
- FfmpegCommandProgress(String message) {
+ DownloadProgress(String message) {
this.message = message;
}
*
* @author yuki
*/
-public class ConvertResult {
+public class DownloadResult {
private final boolean resultValue;
- ConvertResult(boolean b) {
+ DownloadResult(boolean b) {
this.resultValue = b;
}
*
* @author yuki
*/
-public class FfmpegCommand extends SwingWorker<FfmpegCommandResult, FfmpegCommandProgress> {
+public class Ffmpeg extends SwingWorker<FfmpegResult, FfmpegProgress> {
- private static final Logger logger = Logger.getLogger(FfmpegCommand.class.getName());
+ private static final Logger logger = Logger.getLogger(Ffmpeg.class.getName());
private final File commentMiddleFile;
private final File tcommMiddleFile;
private final File TMP_CWS;
private final File convertedVideoFile;
private final ConvertProfile ffmpeg;
- FfmpegCommand(File commentFile, File videoFile, File convertedVideoFile, ConvertProfile ffmpeg,
+ Ffmpeg(File commentFile, File videoFile, File convertedVideoFile, ConvertProfile ffmpeg,
GeneralProfile general) throws IOException {
this.commentFile = commentFile;
this.videoFile = videoFile;
}
@Override
- protected FfmpegCommandResult doInBackground() throws Exception {
+ protected FfmpegResult doInBackground() throws Exception {
try {
return exec();
} finally {
}
}
- private FfmpegCommandResult exec() throws InterruptedException, IOException {
+ private FfmpegResult exec() throws InterruptedException, IOException {
final HideCondition ngSetting = getFfmpeg().getNgSetting();
if (commentFile != null) {
- publish(new FfmpegCommandProgress("コメントの中間ファイルへの変換中"));
+ publish(new FfmpegProgress("コメントの中間ファイルへの変換中"));
boolean conv = ConvertToVideoHook.convert(commentFile, commentMiddleFile, ngSetting.getId(), ngSetting.
getWord());
if (!conv) {
- publish(new FfmpegCommandProgress("コメント変換に失敗。ファイル名に使用できない文字が含まれているか正規表現の間違い?"));
- return new FfmpegCommandResult(false);
+ publish(new FfmpegProgress("コメント変換に失敗。ファイル名に使用できない文字が含まれているか正規表現の間違い?"));
+ return new FfmpegResult(false);
}
}
checkStop();
// }
// }
// stopFlagReturn();
- publish(new FfmpegCommandProgress("動画の変換を開始"));
+ publish(new FfmpegProgress("動画の変換を開始"));
int code;
if ((code = converting_video(videoFile, convertedVideoFile, (commentFile != null), commentMiddleFile.getPath(),
false, tcommMiddleFile.getPath(), getFfmpeg().getFfmpegOption())) == 0) {
- publish(new FfmpegCommandProgress("変換が正常に終了しました。"));
- return new FfmpegCommandResult(true);
+ publish(new FfmpegProgress("変換が正常に終了しました。"));
+ return new FfmpegResult(true);
} else {
- publish(new FfmpegCommandProgress("変換エラー:" + convertedVideoFile.getPath()));
+ publish(new FfmpegProgress("変換エラー:" + convertedVideoFile.getPath()));
}
- return new FfmpegCommandResult(false);
+ return new FfmpegResult(false);
}
private int converting_video(File videoFile, File convertedVideoFile, boolean addComment, String commPath,
while ((e = ebr.readLine()) != null) {
String state = e;
if (state.startsWith("frame=")) {
- publish(new FfmpegCommandProgress(state));
+ publish(new FfmpegProgress(state));
} else if (!state.endsWith("No accelerated colorspace conversion found")) {
logger.log(Level.INFO, e);
}
*
* @author yuki
*/
-public class ConvertProgress {
+public class FfmpegProgress {
private final String message;
- ConvertProgress(String message) {
+ FfmpegProgress(String message) {
this.message = message;
}
*
* @author yuki
*/
-public class FfmpegCommandResult {
+public class FfmpegResult {
private final boolean resultValue;
- FfmpegCommandResult(boolean b) {
+ FfmpegResult(boolean b) {
this.resultValue = b;
}
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
-import saccubus.converter.Converter;
+import saccubus.converter.Download;
import saccubus.converter.classic.profile.Profile;
/**
throw new IOException(e);
}
- Converter conv = new Converter("dummy0", profile);
+ Download conv = new Download("dummy0", profile);
ExecutorService es = Executors.newSingleThreadExecutor();
Future<Boolean> future = es.submit((Callable<Boolean>) conv);
try {
// SProperties setting = SProperties.loadSetting(mail, pass);
// Converter conv = new Converter(tag, setting.toProfile(), TextProgressListener.EMPTY_LISTENER, new ConvertStopFlag(
// ConvertStopFlag.StateChangeListener.EMPTY_LISTENER));
- Converter conv = new Converter(tag, null/*この部分*/);
+ Download conv = new Download(tag, null/*この部分*/);
System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
System.out.println("Saccubus on CUI");
System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import saccubus.ConvertStopFlag;
-import saccubus.converter.Converter;
+import saccubus.converter.Download;
import saccubus.net.TextProgressListener;
/**
public void tableChanged(TableModelEvent e) {
System.out.println(e.getType());
}
-
+
public void exec(){
// Converter conv = new Converter(tag, time, setting.toProfile(), TextProgressListener.EMPTY_LISTENER, new ConvertStopFlag(
// ConvertStopFlag.StateChangeListener.EMPTY_LISTENER));
}
-
+
}
@Test
public void testConverter() throws Exception {
- Converter conv = new Converter("sm7139747", null);
+ Download conv = new Download("sm7139747", null);
conv.call();
}
// /**