+
+ /*
+ * ここからDownloadProfile作成用クラスの定義
+ */
+
+ private class InqubusDownloadProfile implements DownloadProfile {
+
+ private final LoginProfile loginProfile;
+ private final ProxyProfile proxyProfile;
+ private final VideoProfile videoProfile;
+ private final CommentProfile commentProfile;
+ private final GeneralProfile generalProfile;
+
+ private InqubusDownloadProfile() {
+ this.loginProfile = new InqubusLoginProfile();
+ this.proxyProfile = new InqubusProxyProfile();
+ this.videoProfile = new InqubusVideoProfile();
+ this.commentProfile = new InqubusCommentProfile();
+ this.generalProfile = new InqubusGeneralProfile();
+ }
+
+ @Override
+ public LoginProfile getLoginInfo() {
+ return this.loginProfile;
+ }
+
+ @Override
+ public ProxyProfile getProxyProfile() {
+ return this.proxyProfile;
+ }
+
+ @Override
+ public VideoProfile getVideoProfile() {
+ return this.videoProfile;
+ }
+
+ @Override
+ public CommentProfile getCommentProfile() {
+ return this.commentProfile;
+ }
+
+ @Override
+ public GeneralProfile getGeneralProfile() {
+ return this.generalProfile;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusLoginProfile implements LoginProfile {
+ private final String mail;
+ private final String password;
+
+ private InqubusLoginProfile(){
+ final Config p = Config.INSTANCE;
+ this.mail = p.getId();
+ this.password = p.getPassword();
+ }
+
+ @Override
+ public String getMail() {
+ return this.mail;
+ }
+
+ @Override
+ public String getPassword() {
+ return this.password;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusProxyProfile implements ProxyProfile {
+ private final boolean use;
+ private final String host;
+ private final int port;
+
+ private InqubusProxyProfile(){
+ final Config p = Config.INSTANCE;
+ this.use = p.getProxyUse();
+ this.host = p.getProxyHost();
+ final String pp = p.getProxyPort();
+ this.port = StringUtils.isBlank(pp) ? -1 : Integer.parseInt(pp);
+ }
+
+ @Override
+ public boolean use() {
+ return this.use;
+ }
+
+ @Override
+ public String getHost() {
+ return this.host;
+ }
+
+ @Override
+ public int getPort() {
+ return this.port;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusVideoProfile implements VideoProfile {
+ private final boolean download;
+ private final File dir;
+ private final String fileName;
+ private final File localFile;
+
+ private InqubusVideoProfile(){
+ final Config p = Config.INSTANCE;
+ this.download = !cbVideoLocal.isSelected();
+ if (this.download) {
+ this.dir = new File(p.getVideoDir());
+ this.fileName = fldVideo.getText();
+ this.localFile = null;
+ } else {
+ this.dir = null;
+ this.fileName = null;
+ this.localFile = new File(fldVideo.getText());
+ }
+ }
+
+ @Override
+ public boolean isDownload() {
+ return this.download;
+ }
+
+ @Override
+ public File getDir() {
+ return this.dir;
+ }
+
+ @Override
+ public String getFileName() {
+ return this.fileName;
+ }
+
+ @Override
+ public File getLocalFile() {
+ return this.localFile;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusCommentProfile implements CommentProfile {
+ private final boolean download;
+ private final File dir;
+ private final String fileName;
+ private final File localFile;
+ private final int lengthRelatedCommentSize;
+ private final boolean disablePerMinComment;
+ private final int perMinCommentSize;
+ private final long backLogPoint;
+
+ private InqubusCommentProfile() {
+ final Config p = Config.INSTANCE;
+ this.download = !cbCommentLocal.isSelected();
+ if (this.download) {
+ this.dir = new File(p.getCommentDir());
+ this.fileName = fldComment.getText();
+ this.localFile = null;
+ } else {
+ this.dir = null;
+ this.fileName = null;
+ this.localFile = new File(fldComment.getText());
+ }
+
+ if(cbBackLog.isSelected()) {
+ try {
+ this.backLogPoint = WayBackTimeParser.parse(fldBackLog.getText());
+ } catch (IOException ex) {
+ throw new IllegalArgumentException("過去ログ時刻指定が誤っています。", ex);
+ }
+ } else {
+ this.backLogPoint = -1L;
+ }
+
+ this.disablePerMinComment = cbBackLogReduce.isSelected();
+ this.lengthRelatedCommentSize
+ = (p.getCommentSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentSizeManual());
+ this.perMinCommentSize
+ = (p.getCommentMinSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentMinSizeManual());
+ }
+
+ @Override
+ public boolean isDownload() {
+ return this.download;
+ }
+
+ @Override
+ public File getDir() {
+ return this.dir;
+ }
+
+ @Override
+ public String getFileName() {
+ return this.fileName;
+ }
+
+ @Override
+ public File getLocalFile() {
+ return this.localFile;
+ }
+
+ @Override
+ public int getLengthRelatedCommentSize() {
+ return this.lengthRelatedCommentSize;
+ }
+
+ @Override
+ public boolean isDisablePerMinComment() {
+ return this.disablePerMinComment;
+ }
+
+ @Override
+ public int getPerMinCommentSize() {
+ return this.perMinCommentSize;
+ }
+
+ @Override
+ public long getBackLogPoint() {
+ return this.backLogPoint;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusGeneralProfile implements GeneralProfile {
+ private final String replaceFrom;
+ private final String replaceTo;
+ private InqubusGeneralProfile() {
+ final Config p = Config.INSTANCE;
+ this.replaceFrom = p.getReplaceFrom();
+ this.replaceTo = p.getReplaceTo();
+ }
+
+ @Override
+ public String getReplaceFrom() {
+ return this.replaceFrom;
+ }
+
+ @Override
+ public String getReplaceTo() {
+ return this.replaceTo;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ /*
+ * ここからConvertProfile作成用クラスの定義
+ */
+ private class InqubusConvertProfile implements ConvertProfile {
+ private final OutputProfile outputProfile;
+ private final GeneralProfile generalProfile;
+ private final FfmpegProfile ffmpegProfile;
+ private final boolean convert;
+ private final File ffmpeg;
+ private final boolean vhookDisabled;
+ private final boolean commentOverlay;
+ private final File vhook;
+ private final File tmpDir;
+ private final File font;
+ private final int fontIndex;
+ private final boolean commentOpaque;
+ private final boolean disableFontSizeArrange;
+ private final int shadowIndex;
+ private final boolean showConvrting;
+ private final int maxNumOfComment;
+ private final HideCondition ngSetting;
+
+ private InqubusConvertProfile() {
+ final Config p = Config.INSTANCE;
+ this.outputProfile = new InqubusOutputProfile();
+ this.generalProfile = new InqubusGeneralProfile();
+ this.ffmpegProfile = new InqubusFfmpegProfile();
+ this.convert = cbOutputEnable.isSelected();
+ this.ffmpeg = new File(p.getFfmpegPath());
+ // TODO コンフィグに設定なし
+ this.vhookDisabled = false;
+ this.commentOverlay = p.getOutputCommentOverlay();
+ this.vhook = new File(p.getFfmpegDllPath());
+ // TODO コンフィグに設定なし
+ this.tmpDir = new File(".");
+ this.font = new File(p.getFontPath());
+ this.fontIndex = Integer.parseInt(p.getFontIndex());
+ this.commentOpaque = p.getCommentOpaque();
+ this.disableFontSizeArrange = p.getFontSizeArrangeDisable();
+ this.shadowIndex = p.getFontShadow();
+ // TODO コンフィグに設定なし
+ this.showConvrting = true;
+ this.maxNumOfComment = (p.getCommentDisplaySizeDefault()) ? -1 : Integer.parseInt(p.
+ getCommentDisplaySizeManual());
+ this.ngSetting = new InqubusHideCondition();
+ }
+
+ @Override
+ public OutputProfile getOutputProfile() {
+ return this.outputProfile;
+ }
+
+ @Override
+ public GeneralProfile getGeneralProfile() {
+ return this.generalProfile;
+ }
+
+ @Override
+ public FfmpegProfile getFfmpegOption() {
+ return this.ffmpegProfile;
+ }
+
+ @Override
+ public boolean isConvert() {
+ return this.convert;
+ }
+
+ @Override
+ public File getFfmpeg() {
+ return this.ffmpeg;
+ }
+
+ @Override
+ public boolean isVhookDisabled() {
+ return this.vhookDisabled;
+ }
+
+ @Override
+ public boolean isCommentOverlay() {
+ return this.commentOverlay;
+ }
+
+ @Override
+ public File getVhook() {
+ return this.vhook;
+ }
+
+ @Override
+ public File getTempDir() {
+ return this.tmpDir;
+ }
+
+ @Override
+ public File getFont() {
+ return this.font;
+ }
+
+ @Override
+ public int getFontIndex() {
+ return this.fontIndex;
+ }
+
+ @Override
+ public boolean isCommentOpaque() {
+ return this.commentOpaque;
+ }
+
+ @Override
+ public boolean isDisableFontSizeArrange() {
+ return this.disableFontSizeArrange;
+ }
+
+ @Override
+ public int getShadowIndex() {
+ return this.shadowIndex;
+ }
+
+ @Override
+ public boolean isShowConverting() {
+ return this.showConvrting;
+ }
+
+ @Override
+ public int getMaxNumOfComment() {
+ return this.maxNumOfComment;
+ }
+
+ @Override
+ public HideCondition getNgSetting() {
+ return this.ngSetting;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusOutputProfile implements OutputProfile {
+ private final File dir;
+ private final String fileName;
+ private final String videoId;
+ private final String title;
+
+
+ private InqubusOutputProfile(){
+ final Config p = Config.INSTANCE;
+ this.dir = new File(p.getOutputDir());
+ this.fileName = fldOutput.getText();
+ // TODO この時点でのID/Titleはどうするか…
+ this.videoId = "";
+ this.title = "";
+ }
+
+ @Override
+ public File getDir() {
+ return this.dir;
+ }
+
+ @Override
+ public String getFileName() {
+ return this.fileName;
+ }
+
+ @Override
+ public String getVideoId() {
+ return this.videoId;
+ }
+
+ @Override
+ public String getTitile() {
+ return this.title;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusFfmpegProfile implements FfmpegProfile {
+ private final String extOption;
+ private final String inOption;
+ private final String mainOption;
+ private final String outOption;
+ private final String avOption;
+ private final boolean resize;
+ private final int resizeWidth;
+ private final int resizeHeight;
+ private final boolean adjustRatio;
+
+ private InqubusFfmpegProfile() {
+ // TODO FFMPEGオプションは、後でメイン画面でも設定できるようにするかも
+ final Config p = Config.INSTANCE;
+ this.extOption = p.getFfmpegExtension();
+ this.inOption = p.getFfmpegInOption();
+ this.mainOption = p.getFfmpegMainOption();
+ this.outOption = p.getFfmpegOutOption();
+ this.avOption = p.getFfmpegAvOption();
+ this.resize = p.getFfmpegResizeEnable();
+ this.resizeWidth = Integer.parseInt(p.getFfmpegResizeWidth());
+ this.resizeHeight = Integer.parseInt(p.getFfmpegResizeHeight());
+ this.adjustRatio = p.getFfmpegKeepAspect();
+ }
+
+ @Override
+ public String getExtOption() {
+ return this.extOption;
+ }
+
+ @Override
+ public String getInOption() {
+ return this.inOption;
+ }
+
+ @Override
+ public String getMainOption() {
+ return this.mainOption;
+ }
+
+ @Override
+ public String getOutOption() {
+ return this.outOption;
+ }
+
+ @Override
+ public String getAvfilterOption() {
+ return this.avOption;
+ }
+
+ @Override
+ public boolean isResize() {
+ return this.resize;
+ }
+
+ @Override
+ public int getResizeWidth() {
+ return this.resizeWidth;
+ }
+
+ @Override
+ public int getResizeHeight() {
+ return this.resizeHeight;
+ }
+
+ @Override
+ public boolean isAdjustRatio() {
+ return this.adjustRatio;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusHideCondition implements ConvertProfile.HideCondition{
+
+ @Override
+ public String getWord() {
+ // TODO
+ return "";
+ }
+
+ @Override
+ public String getId() {
+ // TODO
+ return "";
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }