import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
-import java.io.IOException;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.SwingUtilities;
import nicobrowser.entity.NicoContent;
import saccubus.ConvertStopFlag.State;
-import saccubus.converter.FfmpegOption;
+import saccubus.converter.profile.FfmpegOption;
+import saccubus.converter.profile.NgSetting;
import saccubus.net.TextProgressListener;
import saccubus.properties.BasicSetting;
import saccubus.properties.ConvertSetting;
private void setSetting(SProperties setting) {
// \8aî\96{\90Ý\92è
final BasicSetting basic = setting.getBasicSetting();
- MailAddrField.setText(basic.getMail());
- PasswordField.setText(basic.getPassword());
+ MailAddrField.setText(basic.getUser().getMail());
+ PasswordField.setText(basic.getUser().getPassword());
// \83v\83\8d\83L\83V\8aÖ\98A
UseProxyCheckBox.setSelected(basic.isProxyUse());
ProxyTextField.setText(basic.getProxyHost());
final boolean videoFixName = inVideo.isAutoNaming();
videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName);
videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName);
+ videoSaveInfoPanel.getNibrFileField().setText(inVideo.getNicoBrowserFile().getPath());
// \95Û\91¶\90Ý\92è - \93ü\97Í\83R\83\81\83\93\83g
final InputCommentSetting inputComment = setting.getInputCommentSetting();
NGIDTextField.setText(conv.getNgSetting().getId());
}
- private FfmpegOption detectOption() throws IOException {
- // TODO detectOption\82ð\8eg\97p\82·\82é\89Ó\8f\8a
- final File ffmpegFile = FFmpegOptionModel.getSelectedFile();
- if (ffmpegFile != null) {
- return FfmpegOption.load(ffmpegFile);
- }
-
- final String extOption = ExtOptionField.getText();
- final String mainOption = MainOptionField.getText();
- final String inOption = CommandLineInOptionField.getText();
- final String outOption = CommandLineOutOptionField.getText();
-
- return new FfmpegOption(extOption, mainOption, inOption, outOption);
- }
-
/**
* [\83t\83@\83C\83\8b|\8fI\97¹] \83A\83N\83V\83\87\83\93\82ª\8eÀ\8ds\82³\82ê\82Ü\82µ\82½\81B
*
Converter = new Converter(url, WayBackField.getText(), getSetting().toProfile(), sl,
new ConvertStopFlag(scl));
-// new ConvertStopFlag(this.DoButton, DoButtonStopString,
-// DoButtonWaitString, DoButtonDefString));
- Converter.start();
+ new Thread(Converter).start();
} else { /* \8aJ\8en\82µ\82Ä\82¢\82é\82Ì\82Å\81A\83X\83g\83b\83v\82·\82é\81B */
final ConvertStopFlag flag = Converter.getStopFlag();
if (!flag.needStop()) { /* \82Ü\82¾\83X\83g\83b\83v\82µ\82Ä\82¢\82È\82¢\81B */
String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText();
String file = videoSaveInfoPanel.getVideoSavedFileField().getText();
boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected();
+ String nibrFile = videoSaveInfoPanel.getNibrFileField().getText();
- return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete);
+ return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
}
private InputCommentSetting getInputCommentSetting() {
File optionFile = FFmpegOptionModel.getSelectedFile();
FfmpegOption opt = new FfmpegOption(ext, main, in, out);
- return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, null);
+ return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
}
private ConvertSetting getConvertSetting() {
boolean showConv = ShowConvVideoCheckBox.isSelected();
boolean adjustFont = FixFontSizeCheckBox.isSelected();
boolean commentOpaque = OpaqueCommentCheckBox.isSelected();
- ConvertSetting.NgSetting ngSetting =
- new ConvertSetting.NgSetting(NGWordTextField.getText(), NGIDTextField.getText());
+ NgSetting ngSetting = new NgSetting(NGWordTextField.getText(), NGIDTextField.getText());
return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont,
commentOpaque, ngSetting);
--- /dev/null
+/* $Id$ */
+package saccubus.converter;
+
+import saccubus.ConvertStopFlag;
+import saccubus.net.TextProgressListener;
+
+/**
+ *
+ * @author yuki
+ */
+public abstract class AbstractCommand {
+
+ private final TextProgressListener listener;
+ private final ConvertStopFlag StopFlag;
+
+ public AbstractCommand(TextProgressListener listener, ConvertStopFlag StopFlag) {
+ this.listener = listener;
+ this.StopFlag = StopFlag;
+ }
+
+ protected void stopFlagReturn() throws InterruptedException {
+ if (getStopFlag().needStop()) {
+ throw new InterruptedException("\92\86\8e~\82µ\82Ü\82µ\82½\81B");
+ }
+ }
+
+ protected void sendText(String text) {
+ getListener().setText(text);
+ }
+
+ /**
+ * @return the listener
+ */
+ protected TextProgressListener getListener() {
+ return listener;
+ }
+
+ /**
+ * @return the StopFlag
+ */
+ protected ConvertStopFlag getStopFlag() {
+ return StopFlag;
+ }
+}
package saccubus.converter;
-import saccubus.converter.filegetter.LoginInfo;
+import saccubus.converter.profile.Profile;
+import saccubus.converter.profile.FfmpegOption;
import saccubus.converter.filegetter.FileInstanciator;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Properties;
import saccubus.ConvertStopFlag;
-import saccubus.conv.ConvertToVideoHook;
import saccubus.net.TextProgressListener;
-import yukihane.swf.Cws2Fws;
/**
* <p>\83^\83C\83g\83\8b: \82³\82«\82ã\82Î\82·</p>
* @author \96¢\93ü\97Í
* @version 1.0
*/
-public class Converter extends Thread {
+public class Converter extends AbstractCommand implements Runnable {
private static final String VIDEO_URL_PARSER = "http://www.nicovideo.jp/watch/";
- private static final String TMP_CWS = "fws_tmp.swf";
private final Profile Setting;
private final String Tag;
private final String Time;
- private final TextProgressListener listener;
- private final ConvertStopFlag StopFlag;
- private final File commentMiddleFile = new File("./vhook.tmp");
- private final File tcommMiddleFile = new File("./tcomment.tmp");
public Converter(String url, String time, Profile setting,
TextProgressListener listener, ConvertStopFlag flag) {
+ super(listener, flag);
url = url.trim();
if (url.startsWith(VIDEO_URL_PARSER)) {
int index = url.indexOf('?', VIDEO_URL_PARSER.length());
}
Time = time;
Setting = setting;
- this.listener = listener;
- StopFlag = flag;
}
@Override
try {
runConvert();
} catch (Exception ex) {
- sendText(ex.getMessage());
+ String text = (ex.getMessage() != null) ? ex.getMessage() : "\97\\8aú\82µ\82È\82¢\83G\83\89\81[\94\90¶\82Ì\82½\82ß\92\86\92f\82µ\82Ü\82µ\82½\81B";
+ sendText(text);
ex.printStackTrace();
} finally {
- if (commentMiddleFile.exists()) {
- commentMiddleFile.delete();
- }
- if (tcommMiddleFile.exists()) {
- tcommMiddleFile.delete();
- }
- StopFlag.finished();
+ getStopFlag().finished();
}
}
}
validSetting();
- final FfmpegOption ov = Setting.getFfmpegOption();
+ final FfmpegOption ov = Setting.getFfmpeg().getFfmpegOption();
sendText("\83\8d\83O\83C\83\93\92\86");
stopFlagReturn();
- final File videoFile = fi.getVideoFile(listener);
+ final File videoFile = fi.getVideoFile(getListener());
stopFlagReturn();
- final File commentFile = fi.getCommentFile(listener);
+ File commentFile = fi.getCommentFile(getListener());
stopFlagReturn();
- final File tcommFile = fi.getTcommFile(listener);
+ File tcommFile = fi.getTcommFile(getListener());
if (!Setting.needsConvert()) {
sendText("\93®\89æ\81E\83R\83\81\83\93\83g\82ð\95Û\91¶\82µ\81A\95Ï\8a·\82Í\8ds\82¢\82Ü\82¹\82ñ\82Å\82µ\82½\81B");
return;
}
+ if (!videoFile.isFile()) {
+ throw new IOException("\93ü\97Í\93®\89æ\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ:" + videoFile.getPath());
+ }
- if (Setting.getAddComment()) {
- sendText("\83R\83\81\83\93\83g\82Ì\92\86\8aÔ\83t\83@\83C\83\8b\82Ö\82Ì\95Ï\8a·\92\86");
-
- boolean conv = ConvertToVideoHook.convert(commentFile, commentMiddleFile,
- Setting.getNgId(), Setting.getNgWord());
- if (!conv) {
- sendText("\83R\83\81\83\93\83g\95Ï\8a·\82É\8e¸\94s\81B\82¨\82»\82ç\82\90³\8bK\95\\8c»\82Ì\8aÔ\88á\82¢\81H");
- return;
+ if (Setting.getOutputFileSetting().isAddComment()) {
+ if (!commentFile.isFile()) {
+ throw new IOException("\93ü\97Í\83R\83\81\83\93\83g\83t\83@\83C\83\8b\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ:" + commentFile.getPath());
}
+ } else {
+ commentFile = null;
}
- stopFlagReturn();
-
- if (Setting.getAddTcomment()) {
- sendText("\93\8a\8de\8eÒ\83R\83\81\83\93\83g\82Ì\92\86\8aÔ\83t\83@\83C\83\8b\82Ö\82Ì\95Ï\8a·\92\86");
-
- boolean conv = ConvertToVideoHook.convert(tcommFile, tcommMiddleFile,
- Setting.getNgId(), Setting.getNgWord());
- if (!conv) {
- sendText("\83R\83\81\83\93\83g\95Ï\8a·\82É\8e¸\94s\81B\82¨\82»\82ç\82\90³\8bK\95\\8c»\82Ì\8aÔ\88á\82¢\81H");
- return;
+ if (Setting.getOutputFileSetting().isAddTcomment()) {
+ if (!tcommFile.isFile()) {
+ throw new IOException("\93ü\97Í\93\8a\8de\8eÒ\83R\83\81\83\93\83g\83t\83@\83C\83\8b\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ:" + tcommFile.getPath());
}
+ } else {
+ tcommFile = null;
}
- stopFlagReturn();
-
- sendText("\93®\89æ\82Ì\95Ï\8a·\82ð\8aJ\8en");
/*\83r\83f\83I\96¼\82Ì\8am\92è*/
File convertedVideoFile;
- if (!Setting.getConvertFile().isFile()) {
+ if (!Setting.getOutputFileSetting().getFile().isFile()) {
if (fi.getVideoTitle() == null) {
sendText("\95Ï\8a·\8cã\82Ì\83r\83f\83I\83t\83@\83C\83\8b\96¼\82ª\8am\92è\82Å\82«\82Ü\82¹\82ñ\81B");
return;
}
String conv_name = fi.getVideoTitle();
- if (Setting.needsAppendPrefixVideoId()) {
+ if (Setting.getOutputFileSetting().isAppendPrefixVideoId()) {
conv_name = getVideoIDWithBracket() + conv_name;
}
- convertedVideoFile = new File(Setting.getConvertFile().getFile(), conv_name + ov.getExtOption());
+ convertedVideoFile = new File(Setting.getOutputFileSetting().getFile().getFile(),
+ conv_name + ov.getExtOption());
} else {
- String filename = Setting.getConvertFile().getFile().getPath();
+ String filename = Setting.getOutputFileSetting().getFile().getFile().getPath();
if (!filename.endsWith(ov.getExtOption())) {
- filename = filename.substring(0, filename.lastIndexOf('.'))
- + ov.getExtOption();
+ filename = filename.substring(0, filename.lastIndexOf('.')) + ov.getExtOption();
convertedVideoFile = new File(filename);
} else {
- convertedVideoFile = Setting.getConvertFile().getFile();
+ convertedVideoFile = Setting.getOutputFileSetting().getFile().getFile();
}
}
- int code;
- if ((code = converting_video(videoFile, convertedVideoFile, Setting.getAddComment(), commentMiddleFile.getPath(),
- Setting.getAddTcomment(), tcommMiddleFile.getPath(), ov)) == 0) {
- sendText("\95Ï\8a·\82ª\90³\8fí\82É\8fI\97¹\82µ\82Ü\82µ\82½\81B");
+
+ boolean res = new FfmpegCommand(getListener(), getStopFlag(), commentFile, tcommFile, videoFile,
+ convertedVideoFile, Setting.getFfmpeg()).execute();
+ if (res) {
if (Setting.getCommentSetting().isDelete()) {
commentFile.delete();
}
if (Setting.getTcommentSetting().isDelete()) {
tcommFile.delete();
}
- } else {
- sendText("\95Ï\8a·\83G\83\89\81[:" + convertedVideoFile.getPath());
}
}
private FileInstanciator createInstanciator() throws IOException {
FileInstanciator fi;
- LoginInfo li = new LoginInfo(Setting.getMailAddress(), Setting.getPassword(), Setting.getProxy());
FileInstanciator.InstanciationType videoType = new FileInstanciator.InstanciationType(Setting.getVideoSetting());
FileInstanciator.CommentInstanciationType commentType = new FileInstanciator.CommentInstanciationType(Setting.
- getCommentSetting(), Setting.isselfAdjustCommentNum(), Setting.getBackComment());
+ getCommentSetting(), Setting.getCommentGetInfo().isselfAdjustCommentNum(), Setting.getCommentGetInfo().
+ getBackComment());
FileInstanciator.InstanciationType tcommType = new FileInstanciator.InstanciationType(
Setting.getTcommentSetting());
- fi = FileInstanciator.create(StopFlag, videoType, commentType, tcommType, li, Tag, Time);
+ fi = FileInstanciator.create(getStopFlag(), videoType, commentType, tcommType, Setting.getLoginInfo(), Tag, Time);
return fi;
}
*/
private void validSetting() {
if (Setting.needsConvert()) {
- File a = new File(Setting.getFfmpegPath());
+ File a = Setting.getFfmpeg().getFfmpeg();
if (!a.canRead()) {
throw new IllegalArgumentException("FFmpeg\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81B");
}
- if (Setting.getVhookPath().indexOf(' ') >= 0) {
+ if (Setting.getFfmpeg().getVhook().getPath().indexOf(' ') >= 0) {
throw new IllegalArgumentException("\82·\82¢\82Ü\82¹\82ñ\81B\8c»\8dÝvhook\83\89\83C\83u\83\89\83\8a\82É\82Í\94¼\8ap\8bó\94\92\82Í\8eg\82¦\82Ü\82¹\82ñ\81B");
}
- a = new File(Setting.getVhookPath());
+ a = Setting.getFfmpeg().getVhook();
if (!a.canRead()) {
throw new IllegalArgumentException("Vhook\83\89\83C\83u\83\89\83\8a\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81B");
}
- a = new File(Setting.getFontPath());
+ a = Setting.getFfmpeg().getFont();
if (!a.canRead()) {
throw new IllegalArgumentException("\83t\83H\83\93\83g\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81B");
}
}
}
- private void sendText(String text) {
- listener.setText(text);
- }
-
- private int converting_video(File videoFile, File convertedVideoFile, boolean addComment, String vhook_path,
- boolean addTcomment, String tcommPath, FfmpegOption ov) throws InterruptedException, IOException {
- File fwsFile = Cws2Fws.createFws(videoFile, new File(TMP_CWS));
-
- StringBuffer sb = new StringBuffer();
- sb.append("\"");
- sb.append(Setting.getFfmpegPath().replace("\\", "\\\\"));
- sb.append("\"");
- sb.append(" -y ");
- sb.append(ov.getMainOption());
- sb.append(" ");
- sb.append(ov.getInOption());
- sb.append(" -i ");
- if (fwsFile == null) {
- sb.append("\"");
- sb.append(videoFile.getPath().replace("\\", "\\\\"));
- sb.append("\"");
- } else {
- sb.append(fwsFile.getPath().replace("\\", "\\\\"));
- }
- sb.append(" ");
- sb.append(ov.getOutOption());
- sb.append(" \"");
- sb.append(convertedVideoFile.getPath().replace("\\", "\\\\"));
- sb.append("\"");
- if (!Setting.isVhookDisabled()) {
- if (!addVhookSetting(sb, addComment, vhook_path, addTcomment, tcommPath)) {
- return -1;
- }
- }
- String cmd = sb.substring(0);
- System.out.println("arg:" + cmd);
- try {
- System.out.println("\n\n----\nProcessing FFmpeg...\n----\n\n");
- Process process = Runtime.getRuntime().exec(cmd);
- BufferedReader ebr = new BufferedReader(new InputStreamReader(
- process.getErrorStream()));
- String e;
- while ((e = ebr.readLine()) != null) {
- String state = e;
- if (state.startsWith("frame=")) {
- sendText(state);
- } else if (!state.endsWith("No accelerated colorspace conversion found")) {
- System.out.println(e);
- }
-
- try {
- stopFlagReturn();
- } catch (InterruptedException ex) {
- process.destroy();
- throw ex;
- }
-
- }
- process.waitFor();
- return process.exitValue();
- } finally {
- if (fwsFile != null) {
- fwsFile.delete();
- }
- }
- }
-
- private boolean addVhookSetting(StringBuffer sb, boolean addComment, String vhook_path, boolean addTcomment,
- String tcommPath) {
- try {
- sb.append(" -vfilters \"vhext=");
- sb.append(Setting.getVhookPath().replace("\\", "/"));
- if (addComment) {
- sb.append("|");
- sb.append("--data-user:");
- sb.append(URLEncoder.encode(vhook_path.replace("\\", "/"), "Shift_JIS"));
- }
- if (addTcomment) {
- sb.append("|");
- sb.append("--data-owner:");
- sb.append(URLEncoder.encode(tcommPath.replace("\\", "/"), "Shift_JIS"));
- }
- sb.append("|");
- sb.append("--font:");
- sb.append(URLEncoder.encode(
- Setting.getFontPath().replace("\\", "/"), "Shift_JIS"));
- sb.append("|");
- sb.append("--font-index:");
- sb.append(Setting.getFontIndex());
- sb.append("|");
- sb.append("--show-user:");
- sb.append(Setting.getVideoShowNum());
- sb.append("|");
- sb.append("--shadow:");
- sb.append(Setting.getShadowIndex());
- sb.append("|");
- if (Setting.isShowConvertingVideo()) {
- sb.append("--enable-show-video");
- sb.append("|");
- }
- if (Setting.isSelfAdjustFontSize()) {
- sb.append("--enable-fix-font-size");
- sb.append("|");
- }
- if (Setting.isOpaqueComment()) {
- sb.append("--enable-opaque-comment");
- }
- sb.append("\"");
- return true;
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- return false;
- }
+ private String getVideoIDWithBracket() {
+ return "[" + Tag + "]";
}
public boolean isConverted() {
- return StopFlag.isFinished();
- }
-
- private void stopFlagReturn() throws InterruptedException {
- if (StopFlag.needStop()) {
- throw new InterruptedException("\92\86\8e~\82µ\82Ü\82µ\82½\81B");
- }
+ return getStopFlag().isFinished();
}
+ @Override
public ConvertStopFlag getStopFlag() {
- return this.StopFlag;
- }
-
- private String getVideoIDWithBracket() {
- return "[" + Tag + "]";
+ return super.getStopFlag();
}
}
--- /dev/null
+/* $Id$ */
+package saccubus.converter;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import saccubus.ConvertStopFlag;
+import saccubus.conv.ConvertToVideoHook;
+import saccubus.converter.profile.Ffmpeg;
+import saccubus.converter.profile.FfmpegOption;
+import saccubus.converter.profile.NgSetting;
+import saccubus.net.TextProgressListener;
+import yukihane.swf.Cws2Fws;
+
+/**
+ *
+ * @author yuki
+ */
+public class FfmpegCommand extends AbstractCommand {
+
+ private final File commentMiddleFile = new File("./vhook.tmp");
+ private final File tcommMiddleFile = new File("./tcomment.tmp");
+ private static final String TMP_CWS = "fws_tmp.swf";
+ private final File commentFile;
+ private final File tcommFile;
+ private final File videoFile;
+ private final File convertedVideoFile;
+ private final Ffmpeg ffmpeg;
+
+ FfmpegCommand(TextProgressListener listener, ConvertStopFlag flag, File commentFile, File tcommFile,
+ File videoFile, File convertedVideoFile, Ffmpeg ffmpeg) {
+ super(listener, flag);
+ this.commentFile = commentFile;
+ this.tcommFile = tcommFile;
+ this.videoFile = videoFile;
+ this.convertedVideoFile = convertedVideoFile;
+ this.ffmpeg = ffmpeg;
+
+ }
+
+ public boolean execute() throws InterruptedException, IOException {
+ try {
+ return exec();
+ } finally {
+ if (commentMiddleFile.exists()) {
+ commentMiddleFile.delete();
+ }
+ if (tcommMiddleFile.exists()) {
+ tcommMiddleFile.delete();
+ }
+ }
+ }
+
+ private boolean exec() throws InterruptedException, IOException {
+ final NgSetting ngSetting = getFfmpeg().getNgSetting();
+ if (commentFile != null) {
+ sendText("\83R\83\81\83\93\83g\82Ì\92\86\8aÔ\83t\83@\83C\83\8b\82Ö\82Ì\95Ï\8a·\92\86");
+ boolean conv = ConvertToVideoHook.convert(commentFile, commentMiddleFile, ngSetting.getId(), ngSetting.
+ getWord());
+ if (!conv) {
+ sendText("\83R\83\81\83\93\83g\95Ï\8a·\82É\8e¸\94s\81B\82¨\82»\82ç\82\90³\8bK\95\\8c»\82Ì\8aÔ\88á\82¢\81H");
+ return false;
+ }
+ }
+ stopFlagReturn();
+ if (tcommFile != null) {
+ sendText("\93\8a\8de\8eÒ\83R\83\81\83\93\83g\82Ì\92\86\8aÔ\83t\83@\83C\83\8b\82Ö\82Ì\95Ï\8a·\92\86");
+ boolean conv = ConvertToVideoHook.convert(tcommFile, tcommMiddleFile, ngSetting.getId(), ngSetting.getWord());
+ if (!conv) {
+ sendText("\83R\83\81\83\93\83g\95Ï\8a·\82É\8e¸\94s\81B\82¨\82»\82ç\82\90³\8bK\95\\8c»\82Ì\8aÔ\88á\82¢\81H");
+ return false;
+ }
+ }
+ stopFlagReturn();
+ sendText("\93®\89æ\82Ì\95Ï\8a·\82ð\8aJ\8en");
+ int code;
+ if ((code = converting_video(videoFile, convertedVideoFile, (commentFile != null), commentMiddleFile.getPath(), (tcommFile
+ != null), tcommMiddleFile.getPath(), getFfmpeg().getFfmpegOption())) == 0) {
+ sendText("\95Ï\8a·\82ª\90³\8fí\82É\8fI\97¹\82µ\82Ü\82µ\82½\81B");
+ return true;
+ } else {
+ sendText("\95Ï\8a·\83G\83\89\81[:" + convertedVideoFile.getPath());
+ }
+ return false;
+ }
+
+ private int converting_video(File videoFile, File convertedVideoFile, boolean addComment, String vhook_path,
+ boolean addTcomment, String tcommPath, FfmpegOption ov) throws InterruptedException, IOException {
+ File fwsFile = Cws2Fws.createFws(videoFile, new File(TMP_CWS));
+
+ StringBuffer sb = new StringBuffer();
+ sb.append("\"");
+ sb.append(getFfmpeg().getFfmpeg().getPath().replace("\\", "\\\\"));
+ sb.append("\"");
+ sb.append(" -y ");
+ sb.append(ov.getMainOption());
+ sb.append(" ");
+ sb.append(ov.getInOption());
+ sb.append(" -i ");
+ if (fwsFile == null) {
+ sb.append("\"");
+ sb.append(videoFile.getPath().replace("\\", "\\\\"));
+ sb.append("\"");
+ } else {
+ sb.append(fwsFile.getPath().replace("\\", "\\\\"));
+ }
+ sb.append(" ");
+ sb.append(ov.getOutOption());
+ sb.append(" \"");
+ sb.append(convertedVideoFile.getPath().replace("\\", "\\\\"));
+ sb.append("\"");
+ if (!getFfmpeg().isVhookDisabled()) {
+ if (!addVhookSetting(sb, addComment, vhook_path, addTcomment, tcommPath)) {
+ return -1;
+ }
+ }
+ String cmd = sb.substring(0);
+ System.out.println("arg:" + cmd);
+ try {
+ System.out.println("\n\n----\nProcessing FFmpeg...\n----\n\n");
+ Process process = Runtime.getRuntime().exec(cmd);
+ BufferedReader ebr = new BufferedReader(new InputStreamReader(
+ process.getErrorStream()));
+ String e;
+ while ((e = ebr.readLine()) != null) {
+ String state = e;
+ if (state.startsWith("frame=")) {
+ sendText(state);
+ } else if (!state.endsWith("No accelerated colorspace conversion found")) {
+ System.out.println(e);
+ }
+
+ try {
+ stopFlagReturn();
+ } catch (InterruptedException ex) {
+ process.destroy();
+ throw ex;
+ }
+
+ }
+ process.waitFor();
+ return process.exitValue();
+ } finally {
+ if (fwsFile != null) {
+ fwsFile.delete();
+ }
+ }
+ }
+
+ private boolean addVhookSetting(StringBuffer sb, boolean addComment, String vhook_path, boolean addTcomment,
+ String tcommPath) {
+ try {
+ sb.append(" -vfilters \"vhext=");
+ sb.append(getFfmpeg().getVhook().getPath().replace("\\", "/"));
+ if (addComment) {
+ sb.append("|");
+ sb.append("--data-user:");
+ sb.append(URLEncoder.encode(vhook_path.replace("\\", "/"), "Shift_JIS"));
+ }
+ if (addTcomment) {
+ sb.append("|");
+ sb.append("--data-owner:");
+ sb.append(URLEncoder.encode(tcommPath.replace("\\", "/"), "Shift_JIS"));
+ }
+ sb.append("|");
+ sb.append("--font:");
+ sb.append(URLEncoder.encode(
+ getFfmpeg().getFont().getPath().replace("\\", "/"), "Shift_JIS"));
+ sb.append("|");
+ sb.append("--font-index:");
+ sb.append(getFfmpeg().getFontIndex());
+ sb.append("|");
+ sb.append("--show-user:");
+ sb.append(getFfmpeg().getMaxNumOfComment());
+ sb.append("|");
+ sb.append("--shadow:");
+ sb.append(getFfmpeg().getShadowIndex());
+ sb.append("|");
+ if (getFfmpeg().isShowConverting()) {
+ sb.append("--enable-show-video");
+ sb.append("|");
+ }
+ if (getFfmpeg().isSelfAdjustFontSize()) {
+ sb.append("--enable-fix-font-size");
+ sb.append("|");
+ }
+ if (getFfmpeg().isCommentOpaque()) {
+ sb.append("--enable-opaque-comment");
+ }
+ sb.append("\"");
+ return true;
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ private Ffmpeg getFfmpeg() {
+ return ffmpeg;
+ }
+}
+++ /dev/null
-/* $Id$ */
-package saccubus.converter;
-
-/**
- *
- * @author yuki
- */
-public class Profile {
-
- private final FileSetting videoSetting;
- private final FileSetting commentSetting;
- private final boolean addComment;
- private final boolean selfAdjustCommentNum;
- private final int backComment;
- private final FileSetting tcommentSetting;
- private final boolean addTcomment;
- private final SFile convertFile;
- private final boolean convert;
- private final boolean appendPrefixVideoId;
- private final String mailAddress;
- private final String password;
- private final Proxy proxy;
- private final String ngId;
- private final String ngWord;
- private final String ffmpegPath;
- private final String vhookPath;
- private final boolean vhookDisabled;
- private final String fontPath;
- private final int fontIndex;
- private final int videoShowNum;
- private final int shadowIndex;
- private final boolean showConvertingVideo;
- private final boolean selfAdjustFontSize;
- private final boolean opaqueComment;
- private final FfmpegOption ffmpegOption;
-
- public Profile(
- FileSetting videoSetting,
- FileSetting commentSetting,
- boolean addComment,
- boolean selfAdjustCommentNum,
- int backComment,
- FileSetting tcommentSetting,
- boolean addTcomment,
- SFile convertFile,
- boolean convert,
- boolean appendPrefixVideoId,
- String mailAddress,
- String password,
- Proxy proxy,
- String ngId,
- String ngWord,
- String ffmpegPath,
- String vhookPath,
- boolean vhookDisabled,
- String fontPath,
- int fontIndex,
- int videoShowNum,
- int shadowIndex,
- boolean showConvertingVideo,
- boolean selfAdjustFontSize,
- boolean opaqueComment,
- FfmpegOption ffmpegOption) {
- this.videoSetting = videoSetting;
- this.commentSetting = commentSetting;
- this.addComment = addComment;
- this.selfAdjustCommentNum = selfAdjustCommentNum;
- this.backComment = backComment;
- this.tcommentSetting = tcommentSetting;
- this.addTcomment = addTcomment;
- this.convertFile = convertFile;
- this.convert = convert;
- this.appendPrefixVideoId = appendPrefixVideoId;
- this.mailAddress = mailAddress;
- this.password = password;
- this.proxy = proxy;
- this.ngId = ngId;
- this.ngWord = ngWord;
- this.ffmpegPath = ffmpegPath;
- this.vhookPath = vhookPath;
- this.vhookDisabled = vhookDisabled;
- this.fontPath = fontPath;
- this.fontIndex = fontIndex;
- this.videoShowNum = videoShowNum;
- this.shadowIndex = shadowIndex;
- this.showConvertingVideo = showConvertingVideo;
- this.selfAdjustFontSize = selfAdjustFontSize;
- this.opaqueComment = opaqueComment;
- this.ffmpegOption = ffmpegOption;
- }
-
- /** @return \89½\82©\8eÀ\8ds\82·\82×\82«\8f\88\97\9d\82ª\82 \82ê\82Îtrue. */
- boolean shouldRun() {
- return needsConvert() || needsDownload();
- }
-
- /** @return \89½\82©\83_\83E\83\93\83\8d\81[\83h\82·\82é\82à\82Ì\82ª\82 \82ê\82Îtrue. */
- boolean needsDownload() {
- return (videoSetting.isDownload() || commentSetting.isDownload() || tcommentSetting.isDownload());
- }
-
- boolean needsConvert() {
- return convert;
- }
-
- FileSetting getVideoSetting() {
- return videoSetting;
- }
-
- FileSetting getCommentSetting() {
- return commentSetting;
- }
-
- FileSetting getTcommentSetting() {
- return tcommentSetting;
- }
-
- SFile getConvertFile() {
- return convertFile;
- }
-
- boolean isselfAdjustCommentNum() {
- return selfAdjustCommentNum;
- }
-
- int getBackComment() {
- return backComment;
- }
-
- boolean getAddComment() {
- return addComment;
- }
-
- boolean getAddTcomment() {
- return addTcomment;
- }
-
- String getNgId() {
- return ngId;
- }
-
- String getNgWord() {
- return ngWord;
- }
-
- /** @return \95Ï\8a·\8cã\82Ì\83t\83@\83C\83\8b\82Ì\90Ú\93ª\82É\93®\89æID\82ð\82Â\82¯\82é\8fê\8d\87\82Ítrue. */
- boolean needsAppendPrefixVideoId() {
- return appendPrefixVideoId;
- }
-
- String getMailAddress() {
- return mailAddress;
- }
-
- String getPassword() {
- return password;
- }
-
- Proxy getProxy() {
- return proxy;
- }
-
- String getFfmpegPath() {
- return ffmpegPath;
- }
-
- String getVhookPath() {
- return vhookPath;
- }
-
- boolean isVhookDisabled() {
- return vhookDisabled;
- }
-
- String getFontPath() {
- return fontPath;
- }
-
- int getFontIndex() {
- return fontIndex;
- }
-
- /** @return \95\\8e¦\83R\83\81\83\93\83g\90\94. */
- int getVideoShowNum() {
- return videoShowNum;
- }
-
- int getShadowIndex() {
- return shadowIndex;
- }
-
- boolean isShowConvertingVideo() {
- return showConvertingVideo;
- }
-
- boolean isSelfAdjustFontSize() {
- return selfAdjustFontSize;
- }
-
- boolean isOpaqueComment() {
- return opaqueComment;
- }
-
- FfmpegOption getFfmpegOption() {
- return ffmpegOption;
- }
-}
import java.io.IOException;
import org.apache.commons.io.FilenameUtils;
import saccubus.ConvertStopFlag;
-import saccubus.converter.FileSetting;
-import saccubus.converter.Profile;
+import saccubus.converter.profile.InputFileSetting;
+import saccubus.converter.profile.Profile;
import saccubus.net.TextProgressListener;
/**
}
String baseName = FilenameUtils.getBaseName(fileName);
int s = baseName.indexOf(getVideoIdWithBracket());
- return baseName.substring(s + 1);
+ return baseName.replace(getVideoIdWithBracket(), "");
}
/**
/**
* \83t\83@\83C\83\8b\82ð\83C\83\93\83X\83^\83\93\83X\89»\82·\82é\95û\96@\82ð\8ew\92è\82·\82é\83N\83\89\83X.
*/
- public InstanciationType(FileSetting fileSetting) {
+ public InstanciationType(InputFileSetting fileSetting) {
this.download = fileSetting.isDownload();
this.autoFileName = !fileSetting.getFile().isFile();
this.initFile = fileSetting.getFile().getFile();
private final boolean autoCommentNum;
private final int backComment;
- public CommentInstanciationType(FileSetting fileSetting, boolean autoCommentNum, int backComment) {
+ public CommentInstanciationType(InputFileSetting fileSetting, boolean autoCommentNum, int backComment) {
super(fileSetting);
this.autoCommentNum = autoCommentNum;
this.backComment = backComment;
*/
package saccubus.converter.filegetter;
-import saccubus.converter.Proxy;
+import saccubus.converter.profile.Proxy;
/**
*
import java.io.IOException;
import saccubus.ConvertStopFlag;
-import saccubus.converter.Proxy;
+import saccubus.converter.profile.Proxy;
import saccubus.net.NicoClient;
import saccubus.net.VideoInfo;
--- /dev/null
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package saccubus.converter.profile;
+
+/**
+ *
+ * @author yuki
+ */
+public class CommentGetInfo {
+
+ private final boolean selfAdjustCommentNum;
+ private final int backComment;
+
+ public CommentGetInfo(boolean selfAdjustCommentNum, int backComment) {
+ this.selfAdjustCommentNum = selfAdjustCommentNum;
+ this.backComment = backComment;
+ }
+
+ public boolean isselfAdjustCommentNum() {
+ return selfAdjustCommentNum;
+ }
+
+ public int getBackComment() {
+ return backComment;
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.converter.profile;
+
+import java.io.File;
+
+/**
+ *
+ * @author yuki
+ */
+public class Ffmpeg {
+
+ private final File ffmpeg;
+ private final File vhook;
+ private final FfmpegOption ffmpegOption;
+ private final boolean vhookDisabled;
+ private final int maxNumOfComment;
+ private final File font;
+ private final int fontIndex;
+ private final int shadowIndex;
+ private final boolean showConverting;
+ private final boolean selfAdjustFontSize;
+ private final boolean commentOpaque;
+ private final NgSetting ngSetting;
+
+ public Ffmpeg(File ffmpegPath, File vhookPath, FfmpegOption ffmpegOption, boolean vhookDisabled,
+ int videoShowNum, File fontPath, int fontIndex, int shadowIndex, boolean showConvertingVideo,
+ boolean selfAdjustFontSize, boolean opaqueComment, NgSetting ngSetting) {
+ this.ffmpeg = ffmpegPath;
+ this.vhook = vhookPath;
+ this.ffmpegOption = ffmpegOption;
+ this.vhookDisabled = vhookDisabled;
+ this.maxNumOfComment = videoShowNum;
+ this.font = fontPath;
+ this.fontIndex = fontIndex;
+ this.shadowIndex = shadowIndex;
+ this.showConverting = showConvertingVideo;
+ this.selfAdjustFontSize = selfAdjustFontSize;
+ this.commentOpaque = opaqueComment;
+ this.ngSetting = ngSetting;
+ }
+
+ public FfmpegOption getFfmpegOption() {
+ return ffmpegOption;
+ }
+
+ public File getFfmpeg() {
+ return ffmpeg;
+ }
+
+ public int getFontIndex() {
+ return fontIndex;
+ }
+
+ public File getFont() {
+ return font;
+ }
+
+ public boolean isCommentOpaque() {
+ return commentOpaque;
+ }
+
+ public boolean isSelfAdjustFontSize() {
+ return selfAdjustFontSize;
+ }
+
+ public int getShadowIndex() {
+ return shadowIndex;
+ }
+
+ public boolean isShowConverting() {
+ return showConverting;
+ }
+
+ public boolean isVhookDisabled() {
+ return vhookDisabled;
+ }
+
+ public File getVhook() {
+ return vhook;
+ }
+
+ public int getMaxNumOfComment() {
+ return maxNumOfComment;
+ }
+
+ public NgSetting getNgSetting() {
+ return ngSetting;
+ }
+}
/* $Id$ */
-package saccubus.converter;
+package saccubus.converter.profile;
import java.io.File;
import java.io.FileInputStream;
return new FfmpegOption(ext, main, in, out);
}
- public FfmpegOption(String extOption, String inOption, String outOption, String mainOption) {
+ public FfmpegOption(String extOption, String mainOption, String inOption, String outOption) {
this.extOption = (extOption.startsWith(".")) ? extOption : "." + extOption;
this.inOption = inOption;
this.outOption = outOption;
/* $Id$ */
-package saccubus.converter;
+package saccubus.converter.profile;
/**
*
* @author yuki
*/
-public class FileSetting {
+public class InputFileSetting {
private final SFile file;
private final boolean download;
* @param download \83_\83E\83\93\83\8d\81[\83h\82·\82é\95K\97v\82ª\82 \82ê\82Îtrue, \83\8d\81[\83J\83\8b\83t\83@\83C\83\8b\82ð\97p\82¢\82é\82Ì\82Å\82 \82ê\82Îfalse.
* @param delete \95Ï\8a·\8cã\82É\83t\83@\83C\83\8b\82ð\8dí\8f\9c\82·\82é\82Ì\82Å\82 \82ê\82Îtrue, \8ec\82µ\82½\82Ü\82Ü\82É\82·\82é\82Ì\82Å\82 \82ê\82Îfalse.
*/
- public FileSetting(SFile file, boolean download, boolean delete) {
+ public InputFileSetting(SFile file, boolean download, boolean delete) {
this.file = file;
this.download = download;
this.delete = delete;
--- /dev/null
+/* $Id$ */
+package saccubus.converter.profile;
+
+/**
+ * NG\90Ý\92è.
+ * @author yuki
+ */
+public class NgSetting {
+
+ private final String word;
+ private final String id;
+
+ public NgSetting(String word, String id) {
+ this.word = word;
+ this.id = id;
+ }
+
+ public String getWord() {
+ return word;
+ }
+
+ public String getId() {
+ return id;
+ }
+}
--- /dev/null
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package saccubus.converter.profile;
+
+/**
+ *
+ * @author yuki
+ */
+public class OutputFileSetting {
+
+ private final SFile file;
+ private final boolean convert;
+ private final boolean appendPrefixVideoId;
+ private final boolean addComment;
+ private final boolean addTcomment;
+
+ public OutputFileSetting(SFile file, boolean convert, boolean appendPrefixVideoId, boolean addComment,
+ boolean addTcomment) {
+ this.file = file;
+ this.convert = convert;
+ this.appendPrefixVideoId = appendPrefixVideoId;
+ this.addComment = addComment;
+ this.addTcomment = addTcomment;
+ }
+
+ public boolean isConvert() {
+ return convert;
+ }
+
+ public boolean isAppendPrefixVideoId() {
+ return appendPrefixVideoId;
+ }
+
+ public boolean isAddComment() {
+ return addComment;
+ }
+
+ public boolean isAddTcomment() {
+ return addTcomment;
+ }
+
+ public SFile getFile() {
+ return file;
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.converter.profile;
+
+import saccubus.converter.filegetter.LoginInfo;
+
+/**
+ * Converter\82É\8f\88\97\9d\82³\82¹\82é\82½\82ß\82Ì\90Ý\92è.
+ * @author yuki
+ */
+public class Profile {
+
+ private final LoginInfo loginInfo;
+ private final InputFileSetting videoSetting;
+ private final InputFileSetting commentSetting;
+ private final CommentGetInfo commentGetInfo;
+ private final InputFileSetting tcommentSetting;
+ private final OutputFileSetting outputFileSetting;
+ private final Ffmpeg ffmpeg;
+
+ public Profile(
+ LoginInfo loginInfo,
+ InputFileSetting videoSetting,
+ InputFileSetting commentSetting,
+ CommentGetInfo commentGetInfo,
+ InputFileSetting tcommentSetting,
+ OutputFileSetting outputFileSetting,
+ Ffmpeg ffmpeg) {
+ this.loginInfo = loginInfo;
+ this.videoSetting = videoSetting;
+ this.commentSetting = commentSetting;
+ this.commentGetInfo = commentGetInfo;
+ this.tcommentSetting = tcommentSetting;
+ this.outputFileSetting = outputFileSetting;
+ this.ffmpeg = ffmpeg;
+ }
+
+ public LoginInfo getLoginInfo() {
+ return loginInfo;
+ }
+
+ /** @return \89½\82©\8eÀ\8ds\82·\82×\82«\8f\88\97\9d\82ª\82 \82ê\82Îtrue. */
+ public boolean shouldRun() {
+ return getOutputFileSetting().isConvert() || needsDownload();
+ }
+
+ /** @return \89½\82©\83_\83E\83\93\83\8d\81[\83h\82·\82é\82à\82Ì\82ª\82 \82ê\82Îtrue. */
+ public boolean needsDownload() {
+ return (videoSetting.isDownload() || commentSetting.isDownload() || tcommentSetting.isDownload());
+ }
+
+ public InputFileSetting getVideoSetting() {
+ return videoSetting;
+ }
+
+ public InputFileSetting getCommentSetting() {
+ return commentSetting;
+ }
+
+ public InputFileSetting getTcommentSetting() {
+ return tcommentSetting;
+ }
+
+ public OutputFileSetting getOutputFileSetting() {
+ return outputFileSetting;
+ }
+
+ public CommentGetInfo getCommentGetInfo() {
+ return commentGetInfo;
+ }
+
+ public boolean needsConvert() {
+ return getOutputFileSetting().isConvert();
+ }
+
+ public Ffmpeg getFfmpeg() {
+ return ffmpeg;
+ }
+}
/* $Id$ */
-package saccubus.converter;
+package saccubus.converter.profile;
import org.apache.commons.lang.StringUtils;
/* $Id$ */
-package saccubus.converter;
+package saccubus.converter.profile;
import java.io.File;
--- /dev/null
+/* $Id$ */
+package saccubus.converter.profile;
+
+/**
+ * \83j\83R\83j\83R\93®\89æ\83\86\81[\83U\90Ý\92è.
+ * @author yuki
+ */
+public class User {
+
+ private final String mail;
+ private final String password;
+
+ public User(String mail, String password) {
+ this.mail = mail;
+ this.password = password;
+ }
+
+ public String getMail() {
+ return mail;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+}
package saccubus.properties;
import java.util.Properties;
+import saccubus.converter.profile.User;
/**
* \8aî\96{\90Ý\92è.
private static final String PROP_USE_PROXY = "UseProxy";
private static final String PROP_PROXY = "Proxy";
private static final String PROP_PROXY_PORT = "ProxyPort";
- private final String mail;
- private final String password;
+ private final User user;
private final boolean proxyUse;
private final String proxyHost;
private final int proxyPort;
public BasicSetting(String mail, String password, boolean proxyUse, String proxyHost, int proxyPort) {
- this.mail = mail;
- this.password = password;
+ this.user = new User(mail, password);
this.proxyUse = proxyUse;
this.proxyHost = proxyHost;
this.proxyPort = proxyPort;
}
- public String getMail() {
- return mail;
- }
-
- public String getPassword() {
- return password;
+ public User getUser() {
+ return user;
}
public String getProxyHost() {
}
public void save(Properties prop) {
- prop.setProperty(PROP_MAILADDR, getMail());
- prop.setProperty(PROP_PASSWORD, getPassword());
+ prop.setProperty(PROP_MAILADDR, getUser().getMail());
+ prop.setProperty(PROP_PASSWORD, getUser().getPassword());
prop.setProperty(PROP_USE_PROXY, Boolean.toString(isProxyUse()));
prop.setProperty(PROP_PROXY, getProxyHost());
prop.setProperty(PROP_PROXY_PORT, Integer.toString(getProxyPort()));
import java.io.File;
import java.util.Properties;
+import saccubus.converter.profile.NgSetting;
/**
* \95Ï\8a·\90Ý\92è.
return new ConvertSetting(vhookDisabled, maxComment, new File(font), fontIndex, shadowIndex, showConv,
adjustFont, opaque, new NgSetting(ngWord, ngId));
}
-
- public static class NgSetting {
-
- private final String word;
- private final String id;
-
- public NgSetting(String word, String id) {
- this.word = word;
- this.id = id;
- }
-
- public String getWord() {
- return word;
- }
-
- public String getId() {
- return id;
- }
- }
}
public class InputVideoSetting extends InputFileSetting<VideoSaveKind> {
private static final String PROP_SAVE_VIDEO = "SaveVideoFile";
- private static final String PROP_VIDEO_FILE = "VideoFile";
private static final String PROP_VIDEO_FIX_FILE_NAME = "VideoFixFileName";
- private static final String PROP_DEL_VIDEO_AFTER_CONV = "DeleteVideoAfterConv";
private static final String PROP_VIDEO_FIX_FILE_NAME_FOLDER = "VideoFixFileNameFolder";
+ private static final String PROP_VIDEO_FILE = "VideoFile";
+ private static final String PROP_DEL_VIDEO_AFTER_CONV = "DeleteVideoAfterConv";
+ private static final String PROP_NICO_BROWSER_FILE_NAME = "NicoBrowserFileName";
+ private final File nicoBrowserFile;
public InputVideoSetting(VideoSaveKind download, boolean autoNaming, File folder,
- File file, boolean deleteAfterConvert) {
+ File file, boolean deleteAfterConvert, File nicoBrowserFile) {
super(download, autoNaming, folder, file, deleteAfterConvert);
+ this.nicoBrowserFile = nicoBrowserFile;
}
public void save(Properties prop) {
prop.setProperty(PROP_VIDEO_FIX_FILE_NAME, Boolean.toString(isAutoNaming()));
prop.setProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, getFolder().getPath());
prop.setProperty(PROP_DEL_VIDEO_AFTER_CONV, Boolean.toString(isDeleteAfterConvert()));
-
-
+ prop.setProperty(PROP_NICO_BROWSER_FILE_NAME, getNicoBrowserFile().getPath());
}
public static InputVideoSetting load(Properties prop) {
String folder = prop.getProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, ".\\[out]video\\");
String file = prop.getProperty(PROP_VIDEO_FILE, ".\\video.flv");
boolean delete = Boolean.parseBoolean(prop.getProperty(PROP_DEL_VIDEO_AFTER_CONV, "false"));
+ String nibrFile = prop.getProperty(PROP_NICO_BROWSER_FILE_NAME, "");
- return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete);
+ return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
}
/** \96{\89Æ\82³\82«\82ã\82Î\82·\82Å\95Û\91¶\82µ\82Ä\82¢\82½\8fê\8d\87\81APROP_SAVE_VIDEO\82Ítrue/false\82È\82Ì\82Å\95Ï\8a·\82·\82é. */
}
return kind;
}
+
+ public File getNicoBrowserFile() {
+ return nicoBrowserFile;
+ }
}
import java.io.File;
import java.util.Properties;
-import saccubus.converter.FfmpegOption;
+import saccubus.converter.profile.FfmpegOption;
/**
* \93®\89æ\90Ý\92è.
package saccubus.properties;
+import java.io.File;
import java.util.Properties;
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.FileInputStream;
-import saccubus.converter.Profile;
+import saccubus.VideoSaveKind;
+import saccubus.converter.filegetter.LoginInfo;
+import saccubus.converter.profile.CommentGetInfo;
+import saccubus.converter.profile.Ffmpeg;
+import saccubus.converter.profile.FfmpegOption;
+import saccubus.converter.profile.InputFileSetting;
+import saccubus.converter.profile.OutputFileSetting;
+import saccubus.converter.profile.Profile;
+import saccubus.converter.profile.Proxy;
+import saccubus.converter.profile.SFile;
/**
* <p>
*/
public class SProperties {
+ private static final String PROP_FILE = "./saccubus.xml";
public static final String[] ShadowKindArray = {
"00:\82È\82µ",
"01:\83j\83R\83j\83R\93®\89æ\95\97",
}
public Profile toProfile() {
- // TODO toProfile\8eÀ\91\95.
- throw new UnsupportedOperationException();
+ return new ProfileBuilder().build();
+ }
+
+ private class ProfileBuilder {
+
+ private Profile build() {
+ LoginInfo loginInfo = buildLoginInfo();
+ InputFileSetting videoSetting = buildVideoSetting();
+ InputFileSetting commentSetting = buildCommentSetting();
+ CommentGetInfo commentGetInfo = buildCommentGetInfo();
+ InputFileSetting tcommentSetting = buildTcommentSetting();
+ OutputFileSetting outputFileSetting = buildOutputFileSetting();
+ Ffmpeg ffmpeg = buildFfmpeg();
+
+ return new Profile(loginInfo, videoSetting, commentSetting, commentGetInfo, tcommentSetting,
+ outputFileSetting, ffmpeg);
+ }
+
+ private LoginInfo buildLoginInfo() {
+ final BasicSetting basic = getBasicSetting();
+ Proxy proxy = Proxy.NO_PROXY;
+ if (basic.isProxyUse()) {
+ proxy = new Proxy(basic.getProxyHost(), basic.getProxyPort());
+ }
+ final LoginInfo loginInfo = new LoginInfo(basic.getUser().getMail(), basic.getUser().getPassword(), proxy);
+ return loginInfo;
+ }
+
+ private InputFileSetting buildVideoSetting() {
+ final InputVideoSetting setting = getInputVideoSetting();
+ // Nicobrowser\83_\83E\83\93\83\8d\81[\83h\83t\83@\83C\83\8b\82Ì\8fê\8d\87\82Í\8fí\82É\83t\83@\83C\83\8b\8ew\92è.
+ final boolean isFile = (!setting.isAutoNaming() || setting.getProcessKind() == VideoSaveKind.NICOBROWSER);
+ File video;
+ if (setting.getProcessKind() == VideoSaveKind.NICOBROWSER) {
+ video = setting.getFile();
+ } else {
+ if (setting.isAutoNaming()) {
+ video = setting.getFolder();
+ } else {
+ video = setting.getFile();
+ }
+ }
+ final SFile videoFile = new SFile(isFile, video);
+ // Nicobrowser\83_\83E\83\93\83\8d\81[\83h\83t\83@\83C\83\8b\82Í\8dí\8f\9c\91Î\8fÛ\82É\82È\82ç\82È\82¢.
+ boolean delete = setting.isDeleteAfterConvert() && (setting.getProcessKind() != VideoSaveKind.NICOBROWSER);
+
+ return new InputFileSetting(videoFile, (setting.getProcessKind() == VideoSaveKind.SAVE), delete);
+ }
+
+ private InputFileSetting buildCommentSetting() {
+ return createCommentSetting(getInputCommentSetting());
+ }
+
+ private CommentGetInfo buildCommentGetInfo() {
+ final InputCommentSetting setting = getInputCommentSetting();
+ return new CommentGetInfo(setting.isSelfAdjustNumOfComment(), setting.getNumOfComment());
+ }
+
+ private InputFileSetting buildTcommentSetting() {
+ return createCommentSetting(getInputTcommentSetting());
+ }
+
+ private InputFileSetting createCommentSetting(saccubus.properties.InputFileSetting<Boolean> setting) {
+ SFile file = createSFile(setting);
+
+ return new InputFileSetting(file, setting.getProcessKind().booleanValue(), setting.isDeleteAfterConvert());
+
+ }
+
+ private SFile createSFile(ProcessFileSetting<Boolean> setting) {
+ File f;
+ if (setting.isAutoNaming()) {
+ f = setting.getFolder();
+ } else {
+ f = setting.getFile();
+ }
+ final SFile file = new SFile(!setting.isAutoNaming(), f);
+ return file;
+ }
+
+ private OutputFileSetting buildOutputFileSetting() {
+ final OutputVideoSetting setting = getOutputVideoSetting();
+
+ SFile file = createSFile(setting);
+ return new OutputFileSetting(file, setting.getProcessKind().booleanValue(), !setting.isCutIdName(), setting.
+ isAddComment(), setting.isAddTcomment());
+ }
+
+ private Ffmpeg buildFfmpeg() {
+ final MovieSetting movie = getMovieSetting();
+ final ConvertSetting conv = getConvertSetting();
+
+ FfmpegOption fo = movie.getFfmpegOption();
+ if (movie.getOptionFile() != null) {
+ try {
+ fo = FfmpegOption.load(movie.getOptionFile());
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ return new Ffmpeg(
+ movie.getFfmpeg(),
+ movie.getVhook(),
+ fo,
+ conv.isVhookDisabled(),
+ conv.getMaxNumOfComment(),
+ conv.getFont(),
+ conv.getFontIndex(),
+ conv.getShadowIndex(),
+ conv.isShowConverting(),
+ conv.isSelfAdjustFontSize(),
+ conv.isCommentOpaque(),
+ conv.getNgSetting());
+ }
}
- private static final String PROP_FILE = "./saccubus.xml";
public static void saveSetting(SProperties setting) {
final Properties prop = new Properties();