<h3>機能</h3>\r
<h4>基本機能</h4>\r
<ul>\r
- <li>さきゅばすver1.22rの全機能</li>\r
+ <li>さきゅばすver1.22rの全機能。</li>\r
<li>投稿者コメントのダウンロード、動画への付与。</li>\r
- <li>nmから始まる動画(swf動画)のダウンロード\r
+ <li>nmから始まる動画(swf動画)のダウンロード。\r
<ul>\r
<li>ただし、変換自体を正しく行えるものは少ないはず(<a href="http://www5.ssw.co.jp/nmm/">ニ\r
-コニコムービーメーカー</a>で作成したものはおそらく正常変換できないだろう) </li>\r
+コニコムービーメーカー</a>で作成したものはおそらく正常変換できないだろう)</li>\r
</ul>\r
</li>\r
+ <li>動画によって(動画名によって)変換処理が上手くいかない状況がある問題の解消。<br>\r
+ </li>\r
</ul>\r
<h4>NicoBrowser拡張機能</h4>\r
<ul>\r
<p><br>\r
</p>\r
<h3> 更新履歴</h3>\r
+<p>2009/12/15 ver.1.1.1<br>\r
+出力ファイルの初期拡張子誤り修正。<br>\r
+</p>\r
+<p>2009/12/13 ver.1.1.0<br>\r
+ファイル名自動命名を指定している場合のファイル名決定ロジックを修正。<br>\r
+変換対象をNicoBrowserにしていたとき、ファイルが存在しないエラーが出る問題の対応。<br>\r
+動画タイトルにファイル名として使用できない文字が含まれている場合に置換する処理を追加。<br>\r
+波ダッシュや全角マイナスが動画名に含まれている場合に変換処理が失敗する問題に対処。<br>\r
+</p>\r
<p>2009/12/09 ver.1.0.0<br>\r
投稿者コメントのダウンロード、変換対応。<br>\r
UIの見直し。<br>\r
<condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">\r
<length length="0" string="${endorsed.classpath}" when="greater"/>\r
</condition>\r
+ <property name="javac.fork" value="false"/>\r
</target>\r
<target name="-post-init">\r
<!-- Empty placeholder for easier customization. -->\r
<sequential>\r
<property location="${build.dir}/empty" name="empty.dir"/>\r
<mkdir dir="${empty.dir}"/>\r
- <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">\r
+ <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
<src>\r
<dirset dir="@{gensrcdir}" erroronmissingdir="false">\r
<include name="*"/>\r
<attribute default="${excludes}" name="excludes"/>\r
<attribute default="**" name="testincludes"/>\r
<sequential>\r
- <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">\r
+ <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">\r
<batchtest todir="${build.test.results.dir}">\r
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">\r
<filename name="@{testincludes}"/>\r
<property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>\r
<delete file="${built-jar.properties}" quiet="true"/>\r
</target>\r
+ <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">\r
+ <echo level="warn" message="Cycle detected: Saccubus was already built"/>\r
+ </target>\r
<target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">\r
<mkdir dir="${build.dir}"/>\r
<touch file="${built-jar.properties}" verbose="false"/>\r
<property file="${built-jar.properties}" prefix="already.built.jar."/>\r
- <fail message="Cycle detected: Saccubus was already built">\r
- <condition>\r
- <isset property="already.built.jar.${basedir}"/>\r
- </condition>\r
- </fail>\r
+ <antcall target="-warn-already-built-jar"/>\r
<propertyfile file="${built-jar.properties}">\r
<entry key="${basedir}" value=""/>\r
</propertyfile>\r
<target name="-do-not-recompile">\r
<property name="javac.includes.binary" value=""/>\r
</target>\r
- <target depends="init,-do-not-recompile,compile-single" name="run-single">\r
+ <target depends="init,compile-single" name="run-single">\r
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>\r
<j2seproject1:java classname="${run.class}"/>\r
</target>\r
- <target depends="init,-do-not-recompile,compile-test-single" name="run-test-with-main">\r
+ <target depends="init,compile-test-single" name="run-test-with-main">\r
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>\r
<j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>\r
</target>\r
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>\r
<j2seproject3:debug classname="${debug.class}"/>\r
</target>\r
- <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>\r
+ <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>\r
<target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">\r
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>\r
<j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>\r
</target>\r
- <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>\r
+ <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>\r
<target depends="init" name="-pre-debug-fix">\r
<fail unless="fix.includes">Must set fix.includes</fail>\r
<property name="javac.includes" value="${fix.includes}.java"/>\r
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">\r
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>\r
</target>\r
- <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>\r
+ <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>\r
<!--\r
=======================\r
JUNIT DEBUGGING SECTION\r
<target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">\r
<j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>\r
</target>\r
- <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>\r
+ <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>\r
<target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">\r
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>\r
</target>\r
<property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>\r
<delete file="${built-clean.properties}" quiet="true"/>\r
</target>\r
+ <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">\r
+ <echo level="warn" message="Cycle detected: Saccubus was already built"/>\r
+ </target>\r
<target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">\r
<mkdir dir="${build.dir}"/>\r
<touch file="${built-clean.properties}" verbose="false"/>\r
<property file="${built-clean.properties}" prefix="already.built.clean."/>\r
- <fail message="Cycle detected: Saccubus was already built">\r
- <condition>\r
- <isset property="already.built.clean.${basedir}"/>\r
- </condition>\r
- </fail>\r
+ <antcall target="-warn-already-built-clean"/>\r
<propertyfile file="${built-clean.properties}">\r
<entry key="${basedir}" value=""/>\r
</propertyfile>\r
</target>\r
<target depends="init" name="-do-clean">\r
<delete dir="${build.dir}"/>\r
- <delete dir="${dist.dir}"/>\r
+ <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>\r
</target>\r
<target name="-post-clean">\r
<!-- Empty placeholder for easier customization. -->\r
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.\r
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.\r
nbproject/build-impl.xml.data.CRC32=57a231c5\r
-nbproject/build-impl.xml.script.CRC32=45a208cd\r
-nbproject/build-impl.xml.stylesheet.CRC32=1022abd3@1.30.1.45\r
+nbproject/build-impl.xml.script.CRC32=3a8e1e42\r
+nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45\r
javadoc.use=true\r
javadoc.version=false\r
javadoc.windowtitle=\r
+jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"\r
jnlp.codebase.type=local\r
jnlp.descriptor=application\r
jnlp.enabled=false\r
+++ /dev/null
-package saccubus;
-
-import java.util.Properties;
-import java.io.IOException;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.File;
-import org.apache.commons.io.FilenameUtils;
-
-/**
- * <p>
- * \83^\83C\83g\83\8b: \82³\82«\82ã\82Î\82·
- * </p>
- *
- * <p>
- * \90à\96¾: \83j\83R\83j\83R\93®\89æ\82Ì\93®\89æ\82ð\83R\83\81\83\93\83g\82Â\82«\82Å\95Û\91¶
- * </p>
- *
- * <p>
- * \92\98\8dì\8c : Copyright (c) 2007 PSI
- * </p>
- *
- * <p>
- * \89ï\8eÐ\96¼:
- * </p>
- *
- * @author \96¢\93ü\97Í
- * @version 1.0
- */
-public class ConvertingSetting {
-
- public static final String[] ShadowKindArray = {
- "00:\82È\82µ",
- "01:\83j\83R\83j\83R\93®\89æ\95\97",
- "02:\89E\89º",
- "03:\88Í\82¢\8d\9e\82Ý"
- };
- private final String MailAddress;
- private final String Password;
- private final VideoSaveKind saveVideo;
- private final File VideoFile;
- private final boolean SaveComment;
- private final File CommentFile;
- private final boolean SaveConverted;
- private final boolean addComment;
- private final boolean addTcomment;
- private final File ConvertedVideoFile;
- private final String FFmpegPath;
- private final String VhookPath;
- private final String CmdLineOptionExt;
- private final String CmdLineOptionIn;
- private final String CmdLineOptionOut;
- private final String CmdLineOptionMain;
- private final String FontPath;
- private final int FontIndex;
- private final String BackComment;
- private final boolean Vhook_ShowConvertingVideo;
- private final int VideoShowNum;
- private final boolean DeleteVideoAfterConverting;
- private final boolean VideoFixFileName;
- private final File VideoFixFileNameFolder;
- private final boolean DeleteCommentAfterConverting;
- private final boolean CommentFixFileName;
- private final File CommentFixFileNameFolder;
- private final TcommentSetting tcommentSetting;
- private final boolean ConvFixFileName;
- private final File ConvFixFileNameFolder;
- private final String NG_Word;
- private final String NG_ID;
- private final boolean UseProxy;
- private final String Proxy;
- private final int ProxyPort;
- private final boolean FixFontSize;
- private final boolean FixCommentNum;
- private final boolean OpaqueComment;
- private final boolean NotAddVideoID_Conv;
- private final File OptionFile;
- private final boolean DisableVhook;
- private final int ShadowIndex;
-
- public ConvertingSetting(
- String mailaddress,
- String password,
- VideoSaveKind savevideo,
- String videofile,
- boolean savecomment,
- String commentfile,
- boolean saveconverted,
- boolean addComment,
- boolean addTcomment,
- String convvideofile,
- String videoshownum,
- String ffmpegpath,
- String vhookpath,
- String cmdlineoption_ext,
- String cmdlineoption_main,
- String cmdlineoption_in,
- String cmdlineoption_out,
- String backcomment,
- String fontpath,
- int font_index,
- boolean showconvvideo,
- boolean delete_video_after_conv,
- boolean video_fix_file_name,
- String video_fix_file_name_folder,
- boolean delete_comment_after_conv,
- boolean comment_fix_file_name,
- String comment_fix_file_name_folder,
- TcommentSetting tcommentSetting,
- boolean not_add_videoid_conv,
- boolean conv_fix_file_name,
- String conv_fix_file_name_folder,
- String ngword,
- String ngid,
- boolean use_proxy,
- String proxy,
- int proxy_port,
- boolean fix_font_size,
- boolean fix_comment_num,
- boolean opaque_comment,
- File option_file, boolean disable_vhook,
- int shadow_index) {
- MailAddress = mailaddress;
- Password = password;
- this.saveVideo = savevideo;
- if (videofile.lastIndexOf(".") < videofile.lastIndexOf("\\")) {
- videofile += ".flv";
- }
- VideoFile = new File(videofile);
- SaveComment = savecomment;
- if (commentfile.lastIndexOf(".") < commentfile.lastIndexOf("\\")) {
- commentfile += ".xml";
- }
- CommentFile = new File(commentfile);
- SaveConverted = saveconverted;
- this.addComment = addComment;
- this.addTcomment = addTcomment;
- if (convvideofile.lastIndexOf(".") < convvideofile.lastIndexOf("\\")) {
- convvideofile += ".avi";
- }
- ConvertedVideoFile = new File(convvideofile);
- int num = 30;
- try {
- num = Integer.parseInt(videoshownum);
- } catch (NumberFormatException ex) {
- }
- VideoShowNum = num;
- FFmpegPath = ffmpegpath;
- VhookPath = vhookpath;
- CmdLineOptionExt = cmdlineoption_ext;
- CmdLineOptionMain = cmdlineoption_main;
- CmdLineOptionIn = cmdlineoption_in;
- CmdLineOptionOut = cmdlineoption_out;
- BackComment = backcomment;
- FontPath = fontpath;
- FontIndex = font_index;
- Vhook_ShowConvertingVideo = showconvvideo;
- DeleteVideoAfterConverting = delete_video_after_conv;
- VideoFixFileName = video_fix_file_name;
- VideoFixFileNameFolder = new File(video_fix_file_name_folder, "");
- DeleteCommentAfterConverting = delete_comment_after_conv;
- CommentFixFileName = comment_fix_file_name;
- CommentFixFileNameFolder = new File(comment_fix_file_name_folder, "");
- this.tcommentSetting = tcommentSetting;
- NotAddVideoID_Conv = not_add_videoid_conv;
- ConvFixFileName = conv_fix_file_name;
- ConvFixFileNameFolder = new File(conv_fix_file_name_folder, "");
- NG_Word = ngword;
- NG_ID = ngid;
- UseProxy = use_proxy;
- Proxy = proxy;
- ProxyPort = proxy_port;
- FixFontSize = fix_font_size;
- FixCommentNum = fix_comment_num;
- OpaqueComment = opaque_comment;
- OptionFile = option_file;
- DisableVhook = disable_vhook;
- ShadowIndex = shadow_index;
- }
-
- public File getVideoFile() {
- return VideoFile;
- }
-
- public File getCommentFile() {
- return CommentFile;
- }
-
- public File getConvertedVideoFile() {
- return ConvertedVideoFile;
- }
-
- public String getFFmpegPath() {
- return FFmpegPath;
- }
-
- public String getVhookPath() {
- return VhookPath;
- }
-
- public String getCmdLineOptionIn() {
- return CmdLineOptionIn;
- }
-
- public String getFontPath() {
- return FontPath;
- }
-
- public String getFontIndex() {
- return Integer.toString(FontIndex);
- }
-
- public boolean isVhook_ShowConvertingVideo() {
- return Vhook_ShowConvertingVideo;
- }
-
- public String getMailAddress() {
- return MailAddress;
- }
-
- public String getPassword() {
- return Password;
- }
-
- public VideoSaveKind getVideoSaveKind() {
- return saveVideo;
- }
-
- public boolean isSaveComment() {
- return SaveComment;
- }
-
- /** @return \81u\83R\83\81\83\93\83g\95t\82«\93®\89æ\82É\95Ï\8a·\82·\82é\81v\82È\82çtrue. */
- public boolean isSaveConverted() {
- return SaveConverted;
- }
- /** @return \95Ï\8a·\93®\89æ\82É\83R\83\81\83\93\83g\82ð\82Â\82¯\82é\82È\82çtrue. */
- public boolean getAddComment() {
- return addComment;
- }
-
- /** @return \95Ï\8a·\93®\89æ\82É\93\8a\8de\8eÒ\83R\83\81\83\93\83g\82ð\82Â\82¯\82é\82È\82çtrue. */
- public boolean getAddTcomment() {
- return addTcomment;
- }
-
-
- public String getCmdLineOptionOut() {
- return CmdLineOptionOut;
- }
-
- public String getBackComment() {
- return BackComment;
- }
-
- public String getVideoShowNum() {
- return Integer.toString(VideoShowNum);
- }
-
- public String getCmdLineOptionExt() {
- return CmdLineOptionExt;
- }
-
- public String getCmdLineOptionMain() {
- return CmdLineOptionMain;
- }
-
- /**
- * @return \93®\89æ\95Û\91¶\90Ý\92è\82Å\81u\95Û\91¶\82·\82é\83t\83H\83\8b\83_\82ð\8ew\92è\82µ\81A\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\82Å\8c\88\92è\82·\82é\81v\82Ì\82Å\82 \82ê\82Îtrue.
- * \81u\95Û\91¶\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é\81v\82Ì\82Å\82 \82ê\82Îfalse.
- */
- public boolean isVideoFixFileName() {
- return VideoFixFileName;
- }
-
- public boolean isDeleteVideoAfterConverting() {
- return DeleteVideoAfterConverting;
- }
-
- public File getVideoFixFileNameFolder() {
- return VideoFixFileNameFolder;
- }
-
- public boolean isCommentFixFileName() {
- return CommentFixFileName;
- }
-
- public boolean isDeleteCommentAfterConverting() {
- return DeleteCommentAfterConverting;
- }
-
- public File getCommentFixFileNameFolder() {
- return CommentFixFileNameFolder;
- }
-
- public boolean isNotAddVideoID_Conv() {
- return NotAddVideoID_Conv;
- }
-
- public boolean isConvFixFileName() {
- return ConvFixFileName;
- }
-
- public File getConvFixFileNameFolder() {
- return ConvFixFileNameFolder;
- }
-
- public String getNG_Word() {
- return NG_Word;
- }
-
- public String getNG_ID() {
- return NG_ID;
- }
-
- public boolean useProxy() {
- return UseProxy;
- }
-
- public String getProxy() {
- return Proxy;
- }
-
- public int getProxyPort() {
- return ProxyPort;
- }
-
- public boolean isFixFontSize() {
- return FixFontSize;
- }
-
- public boolean isFixCommentNum() {
- return FixCommentNum;
- }
-
- public boolean isOpaqueComment() {
- return OpaqueComment;
- }
-
- public File getOptionFile() {
- return OptionFile;
- }
-
- public boolean isVhookDisabled() {
- return DisableVhook;
- }
-
- public int getShadowIndex() {
- return ShadowIndex;
- }
- private static final String PROP_FILE = "./saccubus.xml";
- private static final String PROP_MAILADDR = "MailAddress";
- private static final String PROP_PASSWORD = "Password";
- private static final String PROP_SAVE_VIDEO = "SaveVideoFile";
- private static final String PROP_VIDEO_FILE = "VideoFile";
- private static final String PROP_SAVE_COMMENT = "SaveCommentFile";
- private static final String PROP_COMMENT_FILE = "CommentFile";
- private static final String PROP_SAVE_CONVERTED = "SaveConvertedFile";
- private static final String PROP_ADD_COMMENT = "AddComment";
- private static final String PROP_ADD_TCOMMENT = "AddTcomment";
- private static final String PROP_CONVERTED_FILE = "ConvertedFile";
- private static final String PROP_FFMPEG_PATH = "FFnpegPath";
- private static final String PROP_VHOOK_PATH = "VhookPath";
- private static final String PROP_FONT_PATH = "FontPath";
- private static final String PROP_FONT_INDEX = "FontIndex";
- private static final String PROP_CMDLINE_EXT = "CMD_EXT";
- private static final String PROP_CMDLINE_MAIN = "CMD_MAIN";
- private static final String PROP_CMDLINE_IN = "CMD_IN";
- private static final String PROP_CMDLINE_OUT = "CMD_OUT";
- private static final String PROP_BACK_COMMENT = "BackComment";
- private static final String PROP_SHOW_VIDEO = "ShowVideo";
- private static final String PROP_SHOW_COMMENT = "ShowCommentNum";
- 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_DEL_COMMENT_AFTER_CONV = "DeleteCommentAfterConv";
- private static final String PROP_COMMENT_FIX_FILE_NAME = "CommentFixFileName";
- private static final String PROP_COMMENT_FIX_FILE_NAME_FOLDER = "CommentFixFileNameFolder";
- private static final String PROP_NOT_ADD_VIDEOID_CONV = "NotAddVideoIDtoConverted";
- private static final String PROP_CONV_FIX_FILE_NAME = "ConvFixFileName";
- private static final String PROP_CONV_FIX_FILE_NAME_FOLDER = "ConvFixFileNameFolder";
- private static final String PROP_NG_WORD = "NG_Word";
- private static final String PROP_NG_ID = "NG_ID";
- private static final String PROP_USE_PROXY = "UseProxy";
- private static final String PROP_PROXY = "Proxy";
- private static final String PROP_PROXY_PORT = "ProxyPort";
- private static final String PROP_FIX_FONT_SIZE = "FixFontSize";
- private static final String PROP_FIX_COMMENT_NUM = "FixCommentSize";
- private static final String PROP_OPAQUE_COMMENT = "OpaqueComment";
- private static final String PROP_OPTION_FILE = "OptionFile";
- private static final String PROP_DISABLE_VHOOK = "VhookDisabled";
- private static final String PROP_SHADOW_INDEX = "ShadowIndex";
-
- public static void saveSetting(ConvertingSetting setting) {
- Properties prop = new Properties();
- prop.setProperty(PROP_MAILADDR, setting.getMailAddress());
- prop.setProperty(PROP_PASSWORD, setting.getPassword());
- prop.setProperty(PROP_SAVE_VIDEO, setting.getVideoSaveKind().toString());
- prop.setProperty(PROP_VIDEO_FILE, setting.getVideoFile().getPath());
- prop.setProperty(PROP_SAVE_COMMENT, Boolean.toString(setting.isSaveComment()));
- prop.setProperty(PROP_COMMENT_FILE, setting.getCommentFile().getPath());
- prop.setProperty(PROP_SAVE_CONVERTED, Boolean.toString(setting.isSaveConverted()));
- prop.setProperty(PROP_ADD_COMMENT, Boolean.toString(setting.getAddComment()));
- prop.setProperty(PROP_ADD_TCOMMENT, Boolean.toString(setting.getAddTcomment()));
- prop.setProperty(PROP_SHOW_COMMENT, setting.getVideoShowNum());
- prop.setProperty(PROP_CONVERTED_FILE, setting.getConvertedVideoFile().getPath());
- prop.setProperty(PROP_FFMPEG_PATH, setting.getFFmpegPath());
- prop.setProperty(PROP_VHOOK_PATH, setting.getVhookPath());
- prop.setProperty(PROP_FONT_PATH, setting.getFontPath());
- prop.setProperty(PROP_FONT_INDEX, setting.getFontIndex());
- prop.setProperty(PROP_CMDLINE_EXT, setting.getCmdLineOptionExt());
- prop.setProperty(PROP_CMDLINE_MAIN, setting.getCmdLineOptionMain());
- prop.setProperty(PROP_CMDLINE_IN, setting.getCmdLineOptionIn());
- prop.setProperty(PROP_CMDLINE_OUT, setting.getCmdLineOptionOut());
- prop.setProperty(PROP_BACK_COMMENT, setting.getBackComment());
- prop.setProperty(PROP_SHOW_VIDEO, Boolean.toString((setting.isVhook_ShowConvertingVideo())));
- prop.setProperty(PROP_DEL_VIDEO_AFTER_CONV, Boolean.toString(setting.isDeleteVideoAfterConverting()));
- prop.setProperty(PROP_VIDEO_FIX_FILE_NAME, Boolean.toString(setting.isVideoFixFileName()));
- prop.setProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, setting.getVideoFixFileNameFolder().getPath());
- prop.setProperty(PROP_DEL_COMMENT_AFTER_CONV, Boolean.toString(setting.isDeleteCommentAfterConverting()));
- prop.setProperty(PROP_COMMENT_FIX_FILE_NAME, Boolean.toString(setting.isCommentFixFileName()));
- prop.setProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, setting.getCommentFixFileNameFolder().getPath());
-
- setting.getTcommentSetting().save(prop);
-
- prop.setProperty(PROP_NOT_ADD_VIDEOID_CONV, Boolean.toString(setting.isNotAddVideoID_Conv()));
-
- prop.setProperty(PROP_CONV_FIX_FILE_NAME, (new Boolean(setting.isConvFixFileName())).toString());
- prop.setProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, setting.getConvFixFileNameFolder().getPath());
-
- prop.setProperty(PROP_NG_WORD, setting.getNG_Word());
- prop.setProperty(PROP_NG_ID, setting.getNG_ID());
- prop.setProperty(PROP_USE_PROXY, Boolean.toString(setting.useProxy()));
- prop.setProperty(PROP_PROXY, setting.getProxy());
- prop.setProperty(PROP_PROXY_PORT, Integer.toString(setting.getProxyPort()));
- prop.setProperty(PROP_FIX_FONT_SIZE, Boolean.toString(setting.isFixFontSize()));
- prop.setProperty(PROP_FIX_COMMENT_NUM, Boolean.toString(setting.isFixCommentNum()));
- prop.setProperty(PROP_OPAQUE_COMMENT, Boolean.toString(setting.isOpaqueComment()));
- if (setting.getOptionFile() != null) {
- prop.setProperty(PROP_OPTION_FILE, setting.getOptionFile().getPath());
- }
- prop.setProperty(PROP_DISABLE_VHOOK, Boolean.toString(setting.isVhookDisabled()));
- prop.setProperty(PROP_SHADOW_INDEX, Integer.toString(setting.getShadowIndex()));
- try {
- prop.storeToXML(new FileOutputStream(PROP_FILE), "settings");
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
-
- /** \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é. */
- private static VideoSaveKind convertVideoSaveKind(Properties prop) {
- VideoSaveKind kind;
- String saveVideo = prop.getProperty(PROP_SAVE_VIDEO);
- if (Boolean.toString(true).equals(saveVideo) || saveVideo == null) {
- kind = VideoSaveKind.SAVE;
- } else if (Boolean.toString(false).equals(saveVideo)) {
- kind = VideoSaveKind.NO_SAVE;
- } else {
- kind = VideoSaveKind.valueOf(saveVideo);
- }
- return kind;
- }
-
- public static ConvertingSetting loadSetting(String user, String password) {
- Properties prop = new Properties();
- try {
- prop.loadFromXML(new FileInputStream(PROP_FILE));
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- if (user == null) {
- user = prop.getProperty(PROP_MAILADDR, "");
- }
- if (password == null) {
- password = prop.getProperty(PROP_PASSWORD, "");
- }
- String option_file_name = prop.getProperty(PROP_OPTION_FILE, null);
- File option_file = null;
- if (option_file_name != null) {
- option_file = new File(option_file_name);
- }
- String win_dir = System.getenv("windir");
- if (!win_dir.endsWith("\\")) {
- win_dir = win_dir + "\\";
- }
-
- final VideoSaveKind kind = convertVideoSaveKind(prop);
- return new ConvertingSetting(
- user,
- password,
- kind,
- prop.getProperty(PROP_VIDEO_FILE, ".\\video.flv"),
- Boolean.parseBoolean(prop.getProperty(PROP_SAVE_COMMENT, "true")),
- prop.getProperty(PROP_COMMENT_FILE, ".\\comment.xml"),
- Boolean.parseBoolean(prop.getProperty(PROP_SAVE_CONVERTED, "true")),
- Boolean.valueOf(prop.getProperty(PROP_ADD_COMMENT, "true")),
- Boolean.valueOf(prop.getProperty(PROP_ADD_TCOMMENT, "false")),
- prop.getProperty(PROP_CONVERTED_FILE, ".\\video.avi"),
- prop.getProperty(PROP_SHOW_COMMENT, "30"),
- prop.getProperty(PROP_FFMPEG_PATH, ".\\bin\\ffmpeg.exe"),
- prop.getProperty(PROP_VHOOK_PATH, ".\\bin\\nicovideo.dll"),
- prop.getProperty(PROP_CMDLINE_EXT, "avi"),
- prop.getProperty(PROP_CMDLINE_MAIN, ""),
- prop.getProperty(PROP_CMDLINE_IN, ""),
- prop.getProperty(PROP_CMDLINE_OUT, "-f ipod"),
- prop.getProperty(PROP_BACK_COMMENT, "500"),
- prop.getProperty(PROP_FONT_PATH, win_dir + "Fonts\\msgothic.ttc"),
- Integer.parseInt(prop.getProperty(PROP_FONT_INDEX, "1")),
- Boolean.parseBoolean(prop.getProperty(PROP_SHOW_VIDEO, "true")),
- Boolean.parseBoolean(prop.getProperty(PROP_DEL_VIDEO_AFTER_CONV, "false")),
- Boolean.parseBoolean(prop.getProperty(PROP_VIDEO_FIX_FILE_NAME, "true")),
- prop.getProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, ".\\[in]video\\"),
- Boolean.parseBoolean(prop.getProperty(PROP_DEL_COMMENT_AFTER_CONV, "false")),
- Boolean.parseBoolean(prop.getProperty(PROP_COMMENT_FIX_FILE_NAME, "true")),
- prop.getProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, ".\\[in]comment\\"),
- TcommentSetting.load(prop),
- Boolean.parseBoolean(prop.getProperty(PROP_NOT_ADD_VIDEOID_CONV, "false")),
- Boolean.parseBoolean(prop.getProperty(PROP_CONV_FIX_FILE_NAME, "true")),
- prop.getProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, ".\\[out]converted\\"),
- prop.getProperty(PROP_NG_WORD, ""),
- prop.getProperty(PROP_NG_ID, ""),
- Boolean.parseBoolean(prop.getProperty(PROP_USE_PROXY, "false")),
- prop.getProperty(PROP_PROXY, ""),
- Integer.parseInt(prop.getProperty(PROP_PROXY_PORT, "-1")),
- Boolean.parseBoolean(prop.getProperty(PROP_FIX_FONT_SIZE, "true")),
- Boolean.parseBoolean(prop.getProperty(PROP_FIX_COMMENT_NUM, "true")),
- Boolean.parseBoolean(prop.getProperty(PROP_OPAQUE_COMMENT, "false")),
- option_file, Boolean.parseBoolean(prop.getProperty(PROP_DISABLE_VHOOK, "false")),
- Integer.parseInt(prop.getProperty(PROP_SHADOW_INDEX, "1"),
- 10));
- }
-
- public TcommentSetting getTcommentSetting() {
- return tcommentSetting;
- }
-
- public static class TcommentSetting {
-
- private final boolean download;
- private final boolean delete;
- private final boolean autoFileName;
- private final String inputDirectory;
- private final String inputFile;
-
- public boolean isAutoFileName() {
- return autoFileName;
- }
-
- public boolean isDelete() {
- return delete;
- }
-
- public boolean isDownload() {
- return download;
- }
-
- /** @return \83\86\81[\83U\82ª\81u\95Û\91¶\82·\82é\83t\83H\83\8b\83_\82ð\8ew\92è\82µ\81A\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\82Å\8c\88\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l. */
- public String getInputDirectory() {
- return inputDirectory;
- }
-
- /** @return \83\86\81[\83U\82ª\81u\95Û\91¶\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l. */
- public String getInputFile() {
- return inputFile;
- }
-
- /** @return \95Û\91¶\90æ\83f\83B\83\8c\83N\83g\83\8a. autoFileName\82ªfalse\82Ì\8fê\8d\87\82à, \83t\83@\83C\83\8b\96¼\82Í\93ü\82ç\82È\82¢\82±\82Æ\82É\92\8d\88Ó. */
- public File getDirectory() {
- if (autoFileName) {
- return new File(inputDirectory);
- } else {
- File parent = new File(inputFile).getParentFile();
- if (parent == null) {
- parent = new File("");
- }
- return parent;
- }
- }
-
- /** @return \95Û\91¶\83t\83@\83C\83\8b\96¼. autoFileName\82ªtrue\82È\82ç\8fí\82Énull. */
- public String getFileName() {
- return FilenameUtils.getName(inputFile.toString());
- }
-
- /**
- * \81u\93ü\97Í\93\8a\8de\8eÒ\83R\83\81\83\93\83g\81v\83p\83l\83\8b\82Ì\90Ý\92è.
- * @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\82É\82 \82é\83t\83@\83C\83\8b\82ð\97p\82¢\82é\82Ì\82Å\82 \82ê\82Îfalse.
- * @param delete \8f\88\97\9d\8fI\97¹\8cã\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Îfalse.
- * @param inputDirectory \83\86\81[\83U\82ª\81u\95Û\91¶\82·\82é\83t\83H\83\8b\83_\82ð\8ew\92è\82µ\81A\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\82Å\8c\88\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l.
- * @param inputFile \83\86\81[\83U\82ª\81u\95Û\91¶\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l.
- */
- public TcommentSetting(boolean download, boolean delete, boolean autoFileName, String inputDirectory,
- String inputFile) {
- this.download = download;
- this.delete = delete;
- this.autoFileName = autoFileName;
- this.inputDirectory = inputDirectory;
- this.inputFile = inputFile;
- }
-
- public static TcommentSetting load(Properties prop) {
- String str;
- str = prop.getProperty(PROP_DOWNLOAD, Boolean.toString(true));
- boolean down = Boolean.valueOf(str);
- str = prop.getProperty(PROP_DELETE, Boolean.toString(false));
- boolean del = Boolean.valueOf(str);
- str = prop.getProperty(PROP_AUTOFILENAME, Boolean.toString(true));
- boolean naming = Boolean.valueOf(str);
- String dir = prop.getProperty(PROP_DIRECTORYNAME, ".\\[in]tcomment");
- String f = prop.getProperty(PROP_FILENAME, ".\\tcomment.xml");
- return new TcommentSetting(down, del, naming, dir, f);
- }
-
- public void save(Properties prop) {
- prop.setProperty(PROP_DOWNLOAD, Boolean.toString(download));
- prop.setProperty(PROP_DELETE, Boolean.toString(delete));
- prop.setProperty(PROP_AUTOFILENAME, Boolean.toString(autoFileName));
- prop.setProperty(PROP_DIRECTORYNAME, inputDirectory.toString());
- prop.setProperty(PROP_FILENAME, inputFile.toString());
- }
- private static final String PROP_DOWNLOAD = "TCDownload";
- private static final String PROP_DELETE = "TCDelete";
- private static final String PROP_AUTOFILENAME = "TCAutoNaming";
- private static final String PROP_DIRECTORYNAME = "TCDirectory";
- private static final String PROP_FILENAME = "TCFileName";
- }
-}
package saccubus;
+import saccubus.converter.Converter;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
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.JTextField;
import javax.swing.SwingUtilities;
import nicobrowser.entity.NicoContent;
-import org.apache.commons.io.FilenameUtils;
import saccubus.ConvertStopFlag.State;
-import saccubus.ConvertingSetting.TcommentSetting;
+import saccubus.converter.FfmpegOption;
import saccubus.net.TextProgressListener;
+import saccubus.properties.BasicSetting;
+import saccubus.properties.ConvertSetting;
+import saccubus.properties.InputCommentSetting;
+import saccubus.properties.InputVideoSetting;
+import saccubus.properties.SProperties;
+import saccubus.properties.InputTcommentSetting;
+import saccubus.properties.MovieSetting;
+import saccubus.properties.OutputVideoSetting;
import saccubus.util.FileDropTarget;
import saccubus.util.PopupRightClick;
import yukihane.nicovideo.NicoDBFinder;
public class MainFrame extends JFrame {
private static final long serialVersionUID = 2564486741331062989L;
- public static final String VERSION = "1.22r NicoBrowser\8ag\92£ 1.0.0";
+ public static final String VERSION = "1.22r NicoBrowser\8ag\92£ 1.1.1";
public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource(
"icon32.png"));
JPanel contentPane;
jbInit();
setPopup();
setDropTarget();
- ConvertingSetting setting = ConvertingSetting.loadSetting(null,
+ SProperties setting = SProperties.loadSetting(null,
null);
this.setSetting(setting);
} catch (Exception exception) {
}
}
- private ConvertingSetting getSetting() {
- int back_comment;
- try {
- back_comment = Integer.parseInt(savePanel.getCommentNumField().getText());
- } catch (NumberFormatException ex) {
- back_comment = 500;
- }
- int proxy_port;
- try {
- proxy_port = Integer.parseInt(ProxyPortTextField.getText());
- } catch (NumberFormatException e) {
- proxy_port = -1;
- }
-
- VideoSaveKind kind;
- String savedFileName;
- if (videoSaveInfoPanel.getVideoNoSaveButton().isSelected() == true) {
- kind = VideoSaveKind.NO_SAVE;
- savedFileName = videoSaveInfoPanel.getVideoSavedFileField().getText();
- } else if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected() == true) {
- kind = VideoSaveKind.NICOBROWSER;
- savedFileName = videoSaveInfoPanel.getNibrFileField().getText();
- } else {
- kind = VideoSaveKind.SAVE;
- savedFileName = videoSaveInfoPanel.getVideoSavedFileField().getText();
- }
-
- final ConvertingSetting.TcommentSetting tcommentSetting = getTcommentSetting();
-
- ConvertingSetting setting = new ConvertingSetting(
- MailAddrField.getText(),
- new String(PasswordField.getPassword()),
- kind,
- savedFileName,
- savePanel.getSavingCommentCheckBox().isSelected(),
- savePanel.getCommentSavedFileField().getText(),
- savePanel.getSavingConvertedVideoCheckBox().isSelected(),
- savePanel.getAddCommentCheckBox().isSelected(),
- savePanel.getAddTcommentCheckBox().isSelected(),
- savePanel.getConvertedVideoSavedFileField().getText(),
- ViewCommentField.getText(),
- FFmpegPathField.getText(),
- VhookPathField.getText(),
- ExtOptionField.getText(),
- MainOptionField.getText(),
- CommandLineInOptionField.getText(),
- CommandLineOutOptionField.getText(),
- Integer.toString(back_comment),
- FontPathField.getText(),
- Integer.parseInt(FontIndexField.getText()),
- ShowConvVideoCheckBox.isSelected(),
- videoSaveInfoPanel.getDelVideoCheckBox().isSelected(),
- videoSaveInfoPanel.getSaveFolderRadioButton().isSelected(),
- videoSaveInfoPanel.getVideoSavedFolderField().getText(),
- savePanel.getDelCommentCheckBox().isSelected(),
- savePanel.getCommentSaveFolderRadioButton().isSelected(),
- savePanel.getCommentSavedFolderField().getText(),
- tcommentSetting,
- savePanel.getNotAddVideoIdConvVideoCheckBox().isSelected(),
- savePanel.getConvSaveFolderRadioButton().isSelected(),
- savePanel.getConvertedVideoSavedFolderField().getText(),
- NGWordTextField.getText(),
- NGIDTextField.getText(),
- UseProxyCheckBox.isSelected(),
- ProxyTextField.getText(),
- proxy_port,
- FixFontSizeCheckBox.isSelected(),
- savePanel.getFixCommentNumCheckBox().isSelected(),
- OpaqueCommentCheckBox.isSelected(),
- FFmpegOptionModel.getSelectedFile(),
- NotUseVhookCheckBox.isSelected(),
- ShadowComboBox.getSelectedIndex());
+ private SProperties getSetting() {
+ SProperties setting = new SProperties(
+ getBasicSetting(),
+ getInputVideoSetting(),
+ getInputCommentSetting(),
+ getTcommentSetting(),
+ getOutputVideoSetting(),
+ getMovieSetting(),
+ getConvertSetting());
return setting;
}
* \90Ý\92è\82ð\89æ\96Ê\82É\94½\89f\82·\82é.
* @param setting \94½\89f\82·\82é\90Ý\92è.
*/
- private void setSetting(ConvertingSetting setting) {
- MailAddrField.setText(setting.getMailAddress());
- PasswordField.setText(setting.getPassword());
+ private void setSetting(SProperties setting) {
+ // \8aî\96{\90Ý\92è
+ final BasicSetting basic = setting.getBasicSetting();
+ MailAddrField.setText(basic.getMail());
+ PasswordField.setText(basic.getPassword());
+ // \83v\83\8d\83L\83V\8aÖ\98A
+ UseProxyCheckBox.setSelected(basic.isProxyUse());
+ ProxyTextField.setText(basic.getProxyHost());
+ int proxy_port = basic.getProxyPort();
+ if (proxy_port >= 0 && proxy_port <= 65535) {
+ ProxyPortTextField.setText(Integer.toString(proxy_port));
+ } else {
+ ProxyPortTextField.setText("");
+ }
+ // \95Û\91¶\90Ý\92è - \93ü\97Í\93®\89æ
+ final InputVideoSetting inVideo = setting.getInputVideoSetting();
JRadioButton activeButton;
- switch (setting.getVideoSaveKind()) {
+ switch (inVideo.getProcessKind()) {
case NO_SAVE:
activeButton = videoSaveInfoPanel.getVideoNoSaveButton();
break;
activeButton = videoSaveInfoPanel.getVideoSaveButton();
break;
}
- activeButton.setSelected(true);
- ActionListener[] listeners = activeButton.getActionListeners();
- for (ActionListener l : listeners) {
- l.actionPerformed(new ActionEvent(activeButton, ActionEvent.ACTION_PERFORMED, activeButton.getText()));
- }
-
+ activeButton.doClick();
- videoSaveInfoPanel.getVideoSavedFileField().setText(setting.getVideoFile().getPath());
- savePanel.getSavingCommentCheckBox().setSelected(setting.isSaveComment());
- savePanel.getCommentSavedFileField().setText(setting.getCommentFile().getPath());
- savePanel.getSavingConvertedVideoCheckBox().setSelected(setting.isSaveConverted());
- savePanel.getAddCommentCheckBox().setSelected(setting.getAddComment());
- savePanel.getAddTcommentCheckBox().setSelected(setting.getAddTcomment());
- savePanel.getConvertedVideoSavedFileField().setText(setting.getConvertedVideoFile().getPath());
- ViewCommentField.setText(setting.getVideoShowNum());
- FFmpegPathField.setText(setting.getFFmpegPath());
- VhookPathField.setText(setting.getVhookPath());
- ExtOptionField.setText(setting.getCmdLineOptionExt());
- MainOptionField.setText(setting.getCmdLineOptionMain());
- CommandLineOutOptionField.setText(setting.getCmdLineOptionOut());
- CommandLineInOptionField.setText(setting.getCmdLineOptionIn());
- savePanel.getCommentNumField().setText(setting.getBackComment());
- FontPathField.setText(setting.getFontPath());
- FontIndexField.setText(setting.getFontIndex());
- ShowConvVideoCheckBox.setSelected(setting.isVhook_ShowConvertingVideo());
- videoSaveInfoPanel.getVideoSavedFolderField().setText(setting.getVideoFixFileNameFolder().getPath());
- savePanel.getCommentSavedFolderField().setText(setting.getCommentFixFileNameFolder().getPath());
- savePanel.getConvertedVideoSavedFolderField().setText(setting.getConvFixFileNameFolder().getPath());
- videoSaveInfoPanel.getDelVideoCheckBox().setSelected(setting.isDeleteVideoAfterConverting());
- savePanel.getDelCommentCheckBox().setSelected(setting.isDeleteCommentAfterConverting());
- savePanel.getNotAddVideoIdConvVideoCheckBox().setSelected(setting.isNotAddVideoID_Conv());
-
- boolean videoFixName = setting.isVideoFixFileName();
+ videoSaveInfoPanel.getVideoSavedFileField().setText(inVideo.getFile().getPath());
+ videoSaveInfoPanel.getVideoSavedFolderField().setText(inVideo.getFolder().getPath());
+ videoSaveInfoPanel.getDelVideoCheckBox().setSelected(inVideo.isDeleteAfterConvert());
+ final boolean videoFixName = inVideo.isAutoNaming();
videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName);
videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName);
- boolean commentFixName = setting.isCommentFixFileName();
+ // \95Û\91¶\90Ý\92è - \93ü\97Í\83R\83\81\83\93\83g
+ final InputCommentSetting inputComment = setting.getInputCommentSetting();
+ savePanel.getSavingCommentCheckBox().setSelected(inputComment.getProcessKind());
+ savePanel.getCommentSavedFileField().setText(inputComment.getFile().getPath());
+ savePanel.getDelCommentCheckBox().setSelected(inputComment.isDeleteAfterConvert());
+ savePanel.getCommentSavedFolderField().setText(inputComment.getFolder().getPath());
+ savePanel.getCommentNumField().setText(Integer.toString(inputComment.getNumOfComment()));
+ savePanel.getFixCommentNumCheckBox().setSelected(inputComment.isSelfAdjustNumOfComment());
+ boolean commentFixName = inputComment.isAutoNaming();
savePanel.getCommentSaveFileRadioButton().setSelected(!commentFixName);
savePanel.getCommentSaveFolderRadioButton().setSelected(commentFixName);
- boolean convFixName = setting.isConvFixFileName();
+ // \93\8a\8de\8eÒ\83R\83\81\83\93\83g
+ InputTcommentSetting tcom = setting.getInputTcommentSetting();
+ savePanel.setTcommentDownload(tcom.getProcessKind());
+ savePanel.setTcommentDelete(tcom.isDeleteAfterConvert());
+ savePanel.setTcommentAutoFileName(tcom.isAutoNaming());
+ savePanel.setTcommentDirectoryName(tcom.getFolder().getPath());
+ savePanel.setTcommentFileName(tcom.getFile().getPath());
+
+ // \95Û\91¶\90Ý\92è - \8fo\97Í\83R\83\81\83\93\83g\95t\82«\93®\89æ
+ final OutputVideoSetting outputVideo = setting.getOutputVideoSetting();
+ savePanel.getSavingConvertedVideoCheckBox().setSelected(outputVideo.getProcessKind());
+ savePanel.getAddCommentCheckBox().setSelected(outputVideo.isAddComment());
+ savePanel.getAddTcommentCheckBox().setSelected(outputVideo.isAddTcomment());
+ savePanel.getConvertedVideoSavedFileField().setText(outputVideo.getFile().getPath());
+ savePanel.getConvertedVideoSavedFolderField().setText(outputVideo.getFolder().getPath());
+ savePanel.getNotAddVideoIdConvVideoCheckBox().setSelected(outputVideo.isCutIdName());
+ boolean convFixName = outputVideo.isAutoNaming();
savePanel.getConvSaveFileRadioButton().setSelected(!convFixName);
savePanel.getConvSaveFolderRadioButton().setSelected(convFixName);
- NGWordTextField.setText(setting.getNG_Word());
- NGIDTextField.setText(setting.getNG_ID());
- // \83v\83\8d\83L\83V\8aÖ\98A
- UseProxyCheckBox.setSelected(setting.useProxy());
- ProxyTextField.setText(setting.getProxy());
- int proxy_port = setting.getProxyPort();
- if (proxy_port >= 0 && proxy_port <= 65535) {
- ProxyPortTextField.setText(Integer.toString(proxy_port));
- } else {
- ProxyPortTextField.setText("");
+ // \93®\89æ\90Ý\92è
+ final MovieSetting movie = setting.getMovieSetting();
+ FFmpegPathField.setText(movie.getFfmpeg().toString());
+ VhookPathField.setText(movie.getVhook().toString());
+ ExtOptionField.setText(movie.getFfmpegOption().getExtOption());
+ MainOptionField.setText(movie.getFfmpegOption().getMainOption());
+ CommandLineOutOptionField.setText(movie.getFfmpegOption().getOutOption());
+ CommandLineInOptionField.setText(movie.getFfmpegOption().getInOption());
+ FFmpegOptionModel.reload(movie.getOptionFile());
+
+ // \95Ï\8a·\90Ý\92è
+ final ConvertSetting conv = setting.getConvertSetting();
+ NotUseVhookCheckBox.setSelected(conv.isVhookDisabled());
+ ViewCommentField.setText(Integer.toString(conv.getMaxNumOfComment()));
+ FontPathField.setText(conv.getFont().toString());
+ FontIndexField.setText(Integer.toString(conv.getFontIndex()));
+ ShadowComboBox.setSelectedIndex(conv.getShadowIndex());
+ ShowConvVideoCheckBox.setSelected(conv.isShowConverting());
+ FixFontSizeCheckBox.setSelected(conv.isSelfAdjustFontSize());
+ OpaqueCommentCheckBox.setSelected(conv.isCommentOpaque());
+ NGWordTextField.setText(conv.getNgSetting().getWord());
+ 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);
}
- FixFontSizeCheckBox.setSelected(setting.isFixFontSize());
- savePanel.getFixCommentNumCheckBox().setSelected(setting.isFixCommentNum());
- OpaqueCommentCheckBox.setSelected(setting.isOpaqueComment());
- FFmpegOptionModel.reload(setting.getOptionFile());
- NotUseVhookCheckBox.setSelected(setting.isVhookDisabled());
- ShadowComboBox.setSelectedIndex(setting.getShadowIndex());
- // \93\8a\8de\8eÒ\83R\83\81\83\93\83g
- TcommentSetting tcom = setting.getTcommentSetting();
- savePanel.setTcommentDownload(tcom.isDownload());
- savePanel.setTcommentDelete(tcom.isDelete());
- savePanel.setTcommentAutoFileName(tcom.isAutoFileName());
- savePanel.setTcommentDirectoryName(tcom.getInputDirectory());
- savePanel.setTcommentFileName(tcom.getInputFile());
+ 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);
}
/**
* ActionEvent
*/
void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
- ConvertingSetting setting = this.getSetting();
- ConvertingSetting.saveSetting(setting);
+ SProperties setting = getSetting();
+ SProperties.saveSetting(setting);
System.exit(0);
}
}
};
- Converter = new Converter(url, WayBackField.getText(), this.getSetting(), sl, new ConvertStopFlag(scl));
+ Converter = new Converter(url, WayBackField.getText(), getSetting().toProfile(), sl,
+ new ConvertStopFlag(scl));
// new ConvertStopFlag(this.DoButton, DoButtonStopString,
// DoButtonWaitString, DoButtonDefString));
Converter.start();
*/
private JComboBox getShadowComboBox() {
if (ShadowComboBox == null) {
- ShadowComboBox = new JComboBox(ConvertingSetting.ShadowKindArray);
+ ShadowComboBox = new JComboBox(SProperties.ShadowKindArray);
}
return ShadowComboBox;
}
+ private BasicSetting getBasicSetting() {
+ String mail = MailAddrField.getText();
+ String pass = String.valueOf(PasswordField.getPassword());
+ boolean proxyUse = UseProxyCheckBox.isSelected();
+ String proxyHost = ProxyTextField.getText();
+ int proxyPort;
+ try {
+ proxyPort = Integer.parseInt(ProxyPortTextField.getText());
+ } catch (NumberFormatException e) {
+ proxyPort = -1;
+ }
+ return new BasicSetting(mail, pass, proxyUse, proxyHost, proxyPort);
+ }
+
+ private InputVideoSetting getInputVideoSetting() {
+ VideoSaveKind kind;
+ if (videoSaveInfoPanel.getVideoNoSaveButton().isSelected() == true) {
+ kind = VideoSaveKind.NO_SAVE;
+ } else if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected() == true) {
+ kind = VideoSaveKind.NICOBROWSER;
+ } else {
+ kind = VideoSaveKind.SAVE;
+ }
+ boolean autoNaming = videoSaveInfoPanel.getSaveFolderRadioButton().isSelected();
+ String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText();
+ String file = videoSaveInfoPanel.getVideoSavedFileField().getText();
+ boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected();
+
+ return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete);
+ }
+
+ private InputCommentSetting getInputCommentSetting() {
+ boolean download = savePanel.getSavingCommentCheckBox().isSelected();
+ String file = savePanel.getCommentSavedFileField().getText();
+ int back_comment;
+ try {
+ back_comment = Integer.parseInt(savePanel.getCommentNumField().getText());
+ } catch (NumberFormatException ex) {
+ back_comment = 500;
+ }
+ boolean delete = savePanel.getDelCommentCheckBox().isSelected();
+ boolean autoNaming = savePanel.getCommentSaveFolderRadioButton().isSelected();
+ String folder = savePanel.getCommentSavedFolderField().getText();
+ boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected();
+
+ return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom,
+ back_comment);
+ }
+
/**
* \89æ\96Ê\93ü\97Í\92l\82©\82ç\93\8a\8de\8eÒ\83R\83\81\83\93\83g\90Ý\92è\82ð\8dì\90¬\82·\82é.
* @return \8dì\90¬\82µ\82½\93\8a\8de\8eÒ\83R\83\81\83\93\83g\90Ý\92è.
*/
- private TcommentSetting getTcommentSetting() {
-// TcommentSetting res;
+ private InputTcommentSetting getTcommentSetting() {
boolean down = savePanel.isTcommentDownload();
boolean del = savePanel.isTcommentDelete();
boolean naming = savePanel.isTcommentAutoFileName();
String dir = savePanel.getTcommentDirectoryName();
String f = savePanel.getTcommentFileName();
- return new TcommentSetting(down, del, naming, dir, f);
+ return new InputTcommentSetting(down, naming, dir, f, del);
+ }
+
+ private OutputVideoSetting getOutputVideoSetting() {
+ boolean process = savePanel.getSavingConvertedVideoCheckBox().isSelected();
+ boolean addComment = savePanel.getAddCommentCheckBox().isSelected();
+ boolean addTcomment = savePanel.getAddTcommentCheckBox().isSelected();
+ String file = savePanel.getConvertedVideoSavedFileField().getText();
+ boolean cutId = savePanel.getNotAddVideoIdConvVideoCheckBox().isSelected();
+ boolean autoNaming = savePanel.getConvSaveFolderRadioButton().isSelected();
+ String folder = savePanel.getConvertedVideoSavedFolderField().getText();
+
+ return new OutputVideoSetting(process, autoNaming, new File(folder), new File(file), cutId, addComment,
+ addTcomment);
+ }
+
+ private MovieSetting getMovieSetting() {
+ String ffmpeg = FFmpegPathField.getText();
+ String vhook = VhookPathField.getText();
+ String ext = ExtOptionField.getText();
+ String main = MainOptionField.getText();
+ String in = CommandLineInOptionField.getText();
+ String out = CommandLineOutOptionField.getText();
+ File optionFile = FFmpegOptionModel.getSelectedFile();
+
+ FfmpegOption opt = new FfmpegOption(ext, main, in, out);
+ return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, null);
+ }
+
+ private ConvertSetting getConvertSetting() {
+ boolean vhookDisabled = NotUseVhookCheckBox.isSelected();
+ int maxComment = 30;
+ try {
+ maxComment = Integer.parseInt(ViewCommentField.getText());
+ } catch (NumberFormatException ex) {
+ }
+ File font = new File(FontPathField.getText());
+ int fontIndex = Integer.parseInt(FontIndexField.getText());
+ int shadowIndex = ShadowComboBox.getSelectedIndex();
+ boolean showConv = ShowConvVideoCheckBox.isSelected();
+ boolean adjustFont = FixFontSizeCheckBox.isSelected();
+ boolean commentOpaque = OpaqueCommentCheckBox.isSelected();
+ ConvertSetting.NgSetting ngSetting =
+ new ConvertSetting.NgSetting(NGWordTextField.getText(), NGIDTextField.getText());
+
+ return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont,
+ commentOpaque, ngSetting);
}
private class InputVideoPanelButtonListener implements ActionListener {
+++ /dev/null
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package saccubus;
-
-/**
- *
- * @author yuki
- */
-class OptionValue {
-
- private final String extOption;
- private final String inOption;
- private final String outOption;
- private final String mainOption;
-
- OptionValue(String extOption, String inOption, String outOption, String mainOption) {
- this.extOption = extOption;
- this.inOption = inOption;
- this.outOption = outOption;
- this.mainOption = mainOption;
- }
-
- String getExtOption() {
- return extOption;
- }
-
- String getInOption() {
- return inOption;
- }
-
- String getMainOption() {
- return mainOption;
- }
-
- String getOutOption() {
- return outOption;
- }
-}
-package saccubus;
+package saccubus.converter;
-import saccubus.filegetter.LoginInfo;
-import saccubus.filegetter.FileInstanciator;
+import saccubus.converter.filegetter.LoginInfo;
+import saccubus.converter.filegetter.FileInstanciator;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
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;
private static final String VIDEO_URL_PARSER = "http://www.nicovideo.jp/watch/";
private static final String TMP_CWS = "fws_tmp.swf";
- private final ConvertingSetting Setting;
+ private final Profile Setting;
private final String Tag;
private final String Time;
private final TextProgressListener listener;
private final File commentMiddleFile = new File("./vhook.tmp");
private final File tcommMiddleFile = new File("./tcomment.tmp");
- public Converter(String url, String time, ConvertingSetting setting,
+ public Converter(String url, String time, Profile setting,
TextProgressListener listener, ConvertStopFlag flag) {
url = url.trim();
if (url.startsWith(VIDEO_URL_PARSER)) {
}
private void runConvert() throws IOException, InterruptedException {
- if (!shouldRun()) {
+ if (!Setting.shouldRun()) {
sendText("\89½\82à\82·\82é\82±\82Æ\82ª\82 \82è\82Ü\82¹\82ñ");
return;
}
validSetting();
- final OptionValue ov = detectOption();
+ final FfmpegOption ov = Setting.getFfmpegOption();
sendText("\83\8d\83O\83C\83\93\92\86");
final File tcommFile = fi.getTcommFile(listener);
- if (!Setting.isSaveConverted()) {
+ 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;
}
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.getNG_ID(), Setting.getNG_Word());
+ 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;
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.getNG_ID(), Setting.getNG_Word());
+ 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;
sendText("\93®\89æ\82Ì\95Ï\8a·\82ð\8aJ\8en");
/*\83r\83f\83I\96¼\82Ì\8am\92è*/
File convertedVideoFile;
- if (Setting.isConvFixFileName()) {
+ if (!Setting.getConvertFile().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;
}
- Setting.getConvFixFileNameFolder().mkdir();
String conv_name = fi.getVideoTitle();
- if (!Setting.isNotAddVideoID_Conv()) {//\95t\89Á\82µ\82È\82¢\82È\82ç
+ if (Setting.needsAppendPrefixVideoId()) {
conv_name = getVideoIDWithBracket() + conv_name;
}
- convertedVideoFile = new File(Setting.getConvFixFileNameFolder(), conv_name + ov.getExtOption());
+ convertedVideoFile = new File(Setting.getConvertFile().getFile(), conv_name + ov.getExtOption());
} else {
- String filename = Setting.getConvertedVideoFile().getPath();
+ String filename = Setting.getConvertFile().getFile().getPath();
if (!filename.endsWith(ov.getExtOption())) {
filename = filename.substring(0, filename.lastIndexOf('.'))
+ ov.getExtOption();
convertedVideoFile = new File(filename);
} else {
- convertedVideoFile = Setting.getConvertedVideoFile();
+ convertedVideoFile = Setting.getConvertFile().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");
- if (Setting.isDeleteCommentAfterConverting()) {
+ if (Setting.getCommentSetting().isDelete()) {
commentFile.delete();
}
- if (Setting.isDeleteVideoAfterConverting()) {
+ if (Setting.getVideoSetting().isDelete()) {
videoFile.delete();
}
+ if (Setting.getTcommentSetting().isDelete()) {
+ tcommFile.delete();
+ }
} else {
- sendText("\95Ï\8a·\83G\83\89\81[");
+ 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.useProxy(),
- Setting.getProxy(), Setting.getProxyPort());
-
- File initVFileName;
- File vDir;
- final boolean autoVNaming = Setting.isVideoFixFileName();
- if (autoVNaming) {
- initVFileName = Setting.getVideoFixFileNameFolder();
- vDir = initVFileName;
- } else {
- initVFileName = Setting.getVideoFile();
- vDir = initVFileName.getAbsoluteFile().getParentFile();
- }
- if (vDir == null || !vDir.isDirectory()) {
- throw new IllegalArgumentException("\93ü\97Í\93®\89æ\83f\83B\83\8c\83N\83g\83\8a\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ: " + vDir);
- }
- FileInstanciator.InstanciationType<VideoSaveKind> videoType = new FileInstanciator.InstanciationType<VideoSaveKind>(Setting.
- getVideoSaveKind(), autoVNaming, initVFileName);
-
- File initCFileName;
- File cDir;
- final boolean autoCNaming = Setting.isCommentFixFileName();
- if (autoCNaming) {
- initCFileName = Setting.getCommentFixFileNameFolder();
- cDir = initCFileName;
- } else {
- initCFileName = Setting.getCommentFile();
- cDir = initCFileName.getAbsoluteFile().getParentFile();
- }
- if (cDir == null || !cDir.isDirectory()) {
- throw new IllegalArgumentException("\93ü\97Í\83R\83\81\83\93\83g\83f\83B\83\8c\83N\83g\83\8a\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ: " + cDir);
- }
+ 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.
- isSaveComment(), autoCNaming, initCFileName, Setting.isFixCommentNum(), Setting.getBackComment());
-
- File initTFileName;
- File tDir;
- final boolean autoTNaming = Setting.getTcommentSetting().isAutoFileName();
- tDir = Setting.getTcommentSetting().getDirectory();
- if (!tDir.isDirectory()) {
- throw new IllegalArgumentException("\93ü\97Í\93\8a\8de\8eÒ\83R\83\81\83\93\83g\83f\83B\83\8c\83N\83g\83\8a\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ: " + tDir);
- }
- if (autoTNaming) {
- initTFileName = tDir;
- } else {
- initTFileName = new File(tDir, Setting.getTcommentSetting().getFileName());
- }
- FileInstanciator.InstanciationType<Boolean> tcommType = new FileInstanciator.InstanciationType<Boolean>(
- Setting.getTcommentSetting().isDownload(), autoTNaming, initTFileName);
+ getCommentSetting(), Setting.isselfAdjustCommentNum(), Setting.getBackComment());
+
+ FileInstanciator.InstanciationType tcommType = new FileInstanciator.InstanciationType(
+ Setting.getTcommentSetting());
fi = FileInstanciator.create(StopFlag, videoType, commentType, tcommType, li, Tag, Time);
return fi;
* @throws IllegalArgumentException \90Ý\92è\82É\95s\94õ\82ª\82 \82é\8fê\8d\87.
*/
private void validSetting() {
- if (Setting.isSaveConverted()) {
- File a = new File(Setting.getFFmpegPath());
+ if (Setting.needsConvert()) {
+ File a = new File(Setting.getFfmpegPath());
if (!a.canRead()) {
throw new IllegalArgumentException("FFmpeg\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81B");
}
throw new IllegalArgumentException("\83t\83H\83\93\83g\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81B");
}
} else {
- if (Setting.isDeleteVideoAfterConverting()) {
+ if (Setting.getVideoSetting().isDelete()) {
throw new IllegalArgumentException("\95Ï\8a·\82µ\82È\82¢\82Ì\82É\81A\93®\89æ\8dí\8f\9c\82µ\82¿\82á\82Á\82Ä\97Ç\82¢\82ñ\82Å\82·\82©\81H");
}
- if (Setting.isDeleteCommentAfterConverting()) {
+ if (Setting.getCommentSetting().isDelete()) {
throw new IllegalArgumentException("\95Ï\8a·\82µ\82È\82¢\82Ì\82É\81A\83R\83\81\83\93\83g\8dí\8f\9c\82µ\82¿\82á\82Á\82Ä\97Ç\82¢\82ñ\82Å\82·\82©\81H");
}
+ if (Setting.getTcommentSetting().isDelete()) {
+ throw new IllegalArgumentException("\95Ï\8a·\82µ\82È\82¢\82Ì\82É\81A\93\8a\8de\8eÒ\83R\83\81\83\93\83g\8dí\8f\9c\82µ\82¿\82á\82Á\82Ä\97Ç\82¢\82ñ\82Å\82·\82©\81H");
+ }
}
}
- /** @return \89½\82©\8eÀ\8ds\82·\82×\82«\8f\88\97\9d\82ª\82 \82ê\82Îtrue. */
- private boolean shouldRun() {
- return Setting.isSaveConverted() || needsDownload();
- }
-
- /** @return \89½\82©\83_\83E\83\93\83\8d\81[\83h\82·\82é\82à\82Ì\82ª\82 \82ê\82Îtrue. */
- private boolean needsDownload() {
- return (Setting.getVideoSaveKind() == VideoSaveKind.SAVE) || Setting.isSaveComment();
- }
-
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, OptionValue ov) throws InterruptedException, IOException {
+ 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(Setting.getFfmpegPath().replace("\\", "\\\\"));
sb.append("\"");
sb.append(" -y ");
sb.append(ov.getMainOption());
sb.append("--shadow:");
sb.append(Setting.getShadowIndex());
sb.append("|");
- if (Setting.isVhook_ShowConvertingVideo()) {
+ if (Setting.isShowConvertingVideo()) {
sb.append("--enable-show-video");
sb.append("|");
}
- if (Setting.isFixFontSize()) {
+ if (Setting.isSelfAdjustFontSize()) {
sb.append("--enable-fix-font-size");
sb.append("|");
}
return this.StopFlag;
}
- private OptionValue detectOption() {
- String extOption;
- String inOption;
- String outOption;
- String mainOption;
- if (Setting.getOptionFile() != null) {
- try {
- Properties prop = new Properties();
- prop.loadFromXML(new FileInputStream(Setting.getOptionFile()));
- extOption = prop.getProperty("EXT", null);
- inOption = prop.getProperty("IN", null);
- outOption = prop.getProperty("OUT", null);
- mainOption = prop.getProperty("MAIN", null);
- if (extOption != null && inOption != null && outOption != null
- && mainOption != null) {
- } else {
- throw new IllegalArgumentException("\95Ï\8a·\83I\83v\83V\83\87\83\93\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B");
- }
- } catch (IOException ex) {
- ex.printStackTrace();
- throw new IllegalArgumentException("\95Ï\8a·\83I\83v\83V\83\87\83\93\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B");
- }
- } else {
- extOption = Setting.getCmdLineOptionExt();
- inOption = Setting.getCmdLineOptionIn();
- outOption = Setting.getCmdLineOptionOut();
- mainOption = Setting.getCmdLineOptionMain();
- } //\83I\83v\83V\83\87\83\93\82É\8ag\92£\8eq\82ð\8aÜ\82ñ\82Å\82µ\82Ü\82Á\82½\8fê\8d\87\82É\82à\91Î\89\9e\81\99
- if (!extOption.startsWith(".")) {
- extOption = "." + extOption;
- }
- return new OptionValue(extOption, inOption, outOption, mainOption);
- }
-
private String getVideoIDWithBracket() {
return "[" + Tag + "]";
}
--- /dev/null
+/* $Id$ */
+package saccubus.converter;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ *
+ * @author yuki
+ */
+public class FfmpegOption {
+
+ private final String extOption;
+ private final String inOption;
+ private final String outOption;
+ private final String mainOption;
+
+ public static FfmpegOption load(File file) throws IOException {
+ Properties prop = new Properties();
+ prop.loadFromXML(new FileInputStream(file));
+ String ext = prop.getProperty("EXT");
+ String in = prop.getProperty("IN");
+ String out = prop.getProperty("OUT");
+ String main = prop.getProperty("MAIN");
+ if (ext == null || in == null || out == null || main == null) {
+ throw new IOException("\95Ï\8a·\83I\83v\83V\83\87\83\93\83t\83@\83C\83\8b\8f\91\8e®\8cë\82è\81B");
+ }
+ return new FfmpegOption(ext, main, in, out);
+ }
+
+ public FfmpegOption(String extOption, String inOption, String outOption, String mainOption) {
+ this.extOption = (extOption.startsWith(".")) ? extOption : "." + extOption;
+ this.inOption = inOption;
+ this.outOption = outOption;
+ this.mainOption = mainOption;
+ }
+
+ public String getExtOption() {
+ return extOption;
+ }
+
+ public String getInOption() {
+ return inOption;
+ }
+
+ public String getMainOption() {
+ return mainOption;
+ }
+
+ public String getOutOption() {
+ return outOption;
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.converter;
+
+/**
+ *
+ * @author yuki
+ */
+public class FileSetting {
+
+ private final SFile file;
+ private final boolean download;
+ private final boolean delete;
+
+ /**
+ * @param file \91Î\8fÛ\83t\83@\83C\83\8b.
+ * @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) {
+ this.file = file;
+ this.download = download;
+ this.delete = delete;
+ }
+
+ public SFile getFile() {
+ return file;
+ }
+
+ public boolean isDownload() {
+ return download;
+ }
+
+ public boolean isDelete() {
+ return delete;
+ }
+}
+
--- /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;
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.converter;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ *
+ * @author yuki
+ */
+public class Proxy {
+
+ private String host;
+ private int port;
+ public static final Proxy NO_PROXY = new Proxy();
+
+ private Proxy() {
+ this.host = null;
+ this.port = -1;
+ }
+
+ public Proxy(String host, int port) {
+ if (StringUtils.isEmpty(host) || port < 0 || port > 65535) {
+ throw new IllegalArgumentException("\83v\83\8d\83L\83V\82Ì\90Ý\92è\82ª\95s\93K\90Ø\82Å\82·");
+ }
+ this.host = host;
+ this.port = port;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.converter;
+
+import java.io.File;
+
+/**
+ * \82³\82«\82ã\82Î\82·\82Å\88µ\82¤\83t\83@\83C\83\8b\82Í\81A\81u\95Û\91¶\82·\82é\83f\83B\83\8c\83N\83g\83\8a\81v\82Æ\81A\81u\95Û\91¶\82³\82ê\82½\83t\83@\83C\83\8b\82»\82Ì\82à\82Ì\81v\82Ì2\83p\83^\81[\83\93\82 \82é\81B
+ * \82±\82Ì\83N\83\89\83X\82Í\82±\82ê\82ç\82ð\82Ü\82Æ\82ß\82Ä\88µ\82¤\82½\82ß\82Ì\82à\82Ì\81B
+ * @author yuki
+ */
+public class SFile {
+
+ private final boolean isFile;
+ private final File file;
+
+ /**
+ * @param isFile \83t\83@\83C\83\8b\82Å\82 \82ê\82Îtrue, \83f\83B\83\8c\83N\83g\83\8a\82Å\82 \82ê\82Îfalse.
+ * @param file \82±\82Ì\83I\83u\83W\83F\83N\83g\82ª\8e¦\82·File\83C\83\93\83X\83^\83\93\83X.
+ * @throws IllegalArgumentException \91¶\8dÝ\82µ\82È\82¢\83f\83B\83\8c\83N\83g\83\8a\82ð\8ew\92è\82µ\82½. isFile\82ªtrue\82Ì\8fê\8d\87\81A\90e\83f\83B\83\8c\83N\83g\83\8a\82ª\91¶\8dÝ\82µ\82È\82¢\82Æ\82±\82Ì\97á\8aO\82Æ\82È\82é.
+ */
+ public SFile(boolean isFile, File file) {
+ this.isFile = isFile;
+ this.file = file;
+
+ File dir;
+ if (isFile) {
+ dir = file.getParentFile();
+ } else {
+ dir = file;
+ }
+ if (!dir.isDirectory()) {
+ throw new IllegalArgumentException("\83f\83B\83\8c\83N\83g\83\8a\82ª\91¶\8dÝ\82µ\82Ü\82¹\82ñ:" + dir);
+ }
+ }
+
+ public boolean isFile() {
+ return isFile;
+ }
+
+ public File getFile() {
+ return file;
+ }
+}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
-package saccubus.filegetter;
+package saccubus.converter.filegetter;
import java.io.File;
import saccubus.net.NicoClient;
public class CommentFileWebGetter extends TcommFileWebGetter {
private final boolean autoCommentNum;
- private final String backComment;
+ private final int backComment;
- CommentFileWebGetter(NicoClient client, VideoInfo vi, boolean autoCommentNum, String backComment) {
+ CommentFileWebGetter(NicoClient client, VideoInfo vi, boolean autoCommentNum, int backComment) {
super(client, vi);
this.autoCommentNum = autoCommentNum;
this.backComment = backComment;
@Override
public File get(File file, TextProgressListener listener) {
- String com = this.backComment;
+ String com = Integer.toString(backComment);
if (this.autoCommentNum) {
com = getClient().getBackCommentFromLength(getVideoInfo(), com);
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
-package saccubus.filegetter;
+package saccubus.converter.filegetter;
import java.io.File;
import saccubus.net.TextProgressListener;
/* $Id$ */
-package saccubus.filegetter;
+package saccubus.converter.filegetter;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FilenameUtils;
import saccubus.ConvertStopFlag;
-import saccubus.VideoSaveKind;
+import saccubus.converter.FileSetting;
+import saccubus.converter.Profile;
import saccubus.net.TextProgressListener;
/**
*/
public class FileInstanciator {
- private final InstanciationType<VideoSaveKind> videoType;
- private final InstanciationType<Boolean> commentType;
- private final InstanciationType<Boolean> tcommType;
+ private final InstanciationType videoType;
+ private final InstanciationType commentType;
+ private final InstanciationType tcommType;
private final String videoId;
private FileGetter videoFileGetter;
private FileGetter commentFileGetter;
public static FileInstanciator create(
ConvertStopFlag stopFlag,
- InstanciationType<VideoSaveKind> videoType,
+ InstanciationType videoType,
CommentInstanciationType commentType,
- InstanciationType<Boolean> tcommType,
+ InstanciationType tcommType,
LoginInfo li,
String tag, String time) throws
IOException {
FileInstanciator getter;
- if (videoType.getFileType() == VideoSaveKind.SAVE || commentType.getFileType().booleanValue() || tcommType.
- getFileType().booleanValue()) {
+ if (videoType.isDoanload() || commentType.isDoanload() || tcommType.isDoanload()) {
getter = new WebFileInstanciator(stopFlag, videoType, commentType, tcommType, li, tag, time);
} else {
getter = new FileInstanciator(videoType, commentType, tcommType, tag);
}
protected FileInstanciator(
- InstanciationType<VideoSaveKind> videoType,
- InstanciationType<Boolean> commentType,
- InstanciationType<Boolean> tcommType,
+ InstanciationType videoType,
+ InstanciationType commentType,
+ InstanciationType tcommType,
String videoId) {
this.videoType = videoType;
this.commentType = commentType;
/** @return \93®\89æ\82Ì\83^\83C\83g\83\8b. \95ª\82©\82ç\82È\82¢\8fê\8d\87\82Ínull. */
public String getVideoTitle() {
String fileName = null;
- if (!videoType.isAutoFileName() || videoType.getFileType() == VideoSaveKind.NICOBROWSER) {
+ if (!videoType.isAutoFileName()) {
// \93®\89æ\83t\83@\83C\83\8b\96¼\82ð\92¼\90Ú\8ew\92è\82µ\82Ä\82¢\82é\8fê\8d\87\82Í\81A\82»\82Ì\83t\83@\83C\83\8b\96¼\82ð\8aî\82É\83^\83C\83g\83\8b\82ð\8eæ\93¾\82·\82é.
fileName = videoType.getInitFile().toString();
} else {
* @throws IOException \93®\89æ\83t\83@\83C\83\8b\82ª\91¶\8dÝ\82µ\82È\82¢, \8eæ\93¾\82É\8e¸\94s\82µ\82½.
*/
public final File getVideoFile(TextProgressListener listener) {
- File file = new VideoFileLocator(videoType.getFileType(), videoType.isAutoFileName(), videoType.getInitFile(),
- getVideoIdWithBracket(), getVideoTitle(), ".flv").getFile();
+ File file = new FileLocator(videoType.isAutoFileName(), videoType.getInitFile(), getVideoIdWithBracket(),
+ getVideoTitle(), ".flv").getFile();
file = videoFileGetter.get(file, listener);
return file;
}
return "[" + videoId + "]";
}
- public static class InstanciationType<T> {
+ public static class InstanciationType {
- private final T fileType;
+ private final boolean download;
private final boolean autoFileName;
private final File initFile;
/**
* \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.
- * @param fileType \83t\83@\83C\83\8b\82Ì\8eí\97Þ\82ð\8ew\92è\82·\82é.
- * @param autoFileName \83t\83@\83C\83\8b\96¼\82ð\8e©\93®\96½\96¼\82·\82é\82È\82çtrue, \92¼\90Ú\8ew\92è\82·\82é\82È\82çfalse.
- * @param initFileName \83t\83@\83C\83\8b\8fî\95ñ. autoFileName\82ªtrue\82Å\82 \82ê\82Î\95Û\91¶\82·\82é\83f\83B\83\8c\83N\83g\83\8a\96¼\82ð, false\82È\82ç\95Û\91¶\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é.
*/
- public InstanciationType(T fileType, boolean autoFileName, File initFileName) {
- this.fileType = fileType;
- this.autoFileName = autoFileName;
- this.initFile = initFileName;
+ public InstanciationType(FileSetting fileSetting) {
+ this.download = fileSetting.isDownload();
+ this.autoFileName = !fileSetting.getFile().isFile();
+ this.initFile = fileSetting.getFile().getFile();
}
- public T getFileType() {
- return fileType;
+ public boolean isDoanload() {
+ return download;
}
public File getInitFile() {
}
}
- public static class CommentInstanciationType extends InstanciationType<Boolean> {
+ public static class CommentInstanciationType extends InstanciationType {
private final boolean autoCommentNum;
- private final String backComment;
+ private final int backComment;
- public CommentInstanciationType(Boolean fileType, boolean autoFileName, File initFileName,
- boolean autoCommentNum, String backComment) {
- super(fileType, autoFileName, initFileName);
+ public CommentInstanciationType(FileSetting fileSetting, boolean autoCommentNum, int backComment) {
+ super(fileSetting);
this.autoCommentNum = autoCommentNum;
this.backComment = backComment;
}
return autoCommentNum;
}
- public String getBackComment() {
+ public int getBackComment() {
return backComment;
}
}
--- /dev/null
+/* $Id$ */
+package saccubus.converter.filegetter;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ *
+ * @author yuki
+ */
+class FileLocator {
+
+ private final boolean autoFileName;
+ private final File initFile;
+ private final String prefix;
+ private final String title;
+ private final String suffix;
+
+ FileLocator(boolean autoFileName, File initFile, String prefix, String title, String suffix) {
+ this.autoFileName = autoFileName;
+ this.initFile = initFile;
+ this.prefix = prefix;
+ this.title = title;
+ this.suffix = suffix;
+ }
+
+ /**
+ * \83R\83\93\83X\83g\83\89\83N\83^\82Å\8ew\92è\82µ\82½\8fð\8c\8f\82Å\83t\83@\83C\83\8b\82ð\8c\9f\8dõ\82·\82é\81B
+ * autoFileName\82ªfalse\82Ì\8fê\8d\87\81A\92¼\90Ú\96¼\91O\8ew\92è\82Å\82 \82é\82½\82ß\8ew\92è\82³\82ê\82½\83t\83@\83C\83\8b\82ð\82»\82Ì\82Ü\82Ü\95Ô\82·\81B
+ * autoFileName\82ªtrue\82Ì\8fê\8d\87\81AinitFile\83f\83B\83\8c\83N\83g\83\8a\82Éprefix\82Å\8en\82Ü\82é\83t\83@\83C\83\8b\82ª\91¶\8dÝ\82·\82é\82©\8c\9f\8dõ\82µ
+ * \82 \82ê\82Î\82»\82ê\82ð\95Ô\82·\81B
+ * \82±\82Ì\83t\83@\83C\83\8b\82à\96³\82¢\8fê\8d\87\81A\8ew\92è\82³\82ê\82½\83p\83\89\83\81\81[\83^\82É\8f]\82Á\82½\83t\83@\83C\83\8b\96¼\82ð\95Ô\82·\81B
+ * @return \8f\8a\96]\82Ì\83t\83@\83C\83\8b\81B\83t\83@\83C\83\8b\82Í\91¶\8dÝ\82·\82é\8fê\8d\87\82à\82 \82è\81A\91¶\8dÝ\82µ\82È\82¢\8fê\8d\87\82à\82 \82é\82±\82Æ\82É\92\8d\88Ó\81B
+ */
+ File getFile() {
+ if (!isAutoNaming()) {
+ return initFile;
+ } else {
+ File res = searchFile();
+ if (res != null) {
+ return res;
+ }
+ return new File(initFile, prefix + title + suffix);
+ }
+ }
+
+ private final File searchFile() {
+ FilenameFilter filter = new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ return (name.startsWith(prefix)) ? true : false;
+ }
+ };
+ File[] res = initFile.listFiles(filter);
+ if (res == null || res.length == 0) {
+ return null;
+ }
+ return res[0];
+ }
+
+ protected boolean isAutoNaming() {
+ return autoFileName;
+ }
+
+ protected final boolean getAutoFileName() {
+ return autoFileName;
+ }
+}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
-package saccubus.filegetter;
+package saccubus.converter.filegetter;
+
+import saccubus.converter.Proxy;
/**
*
private final String mail;
private final String pass;
- private final boolean useProxy;
- private final String proxy;
- private final int port;
+ private final Proxy proxy;
- public LoginInfo(String mail, String pass, boolean useProxy, String proxy, int port) {
+ public LoginInfo(String mail, String pass, Proxy proxy) {
this.mail = mail;
this.pass = pass;
- this.useProxy = useProxy;
this.proxy = proxy;
- this.port = port;
}
public String getMail() {
return pass;
}
- public boolean isUseProxy() {
- return useProxy;
- }
-
- public String getProxy() {
+ public Proxy getProxy() {
return proxy;
}
-
- public int getPort() {
- return port;
- }
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
-package saccubus.filegetter;
+package saccubus.converter.filegetter;
import java.io.File;
import saccubus.net.NicoClient;
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
-package saccubus.filegetter;
+package saccubus.converter.filegetter;
import java.io.File;
import saccubus.net.NicoClient;
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package saccubus.filegetter;
+/* $Id$ */
+package saccubus.converter.filegetter;
import java.io.IOException;
import saccubus.ConvertStopFlag;
-import saccubus.VideoSaveKind;
+import saccubus.converter.Proxy;
import saccubus.net.NicoClient;
import saccubus.net.VideoInfo;
WebFileInstanciator(
ConvertStopFlag stopFlag,
- InstanciationType<VideoSaveKind> videoType,
+ InstanciationType videoType,
CommentInstanciationType commentType,
- InstanciationType<Boolean> tcommType,
+ InstanciationType tcommType,
LoginInfo li,
String tag,
String time) throws IOException {
if (li.getMail() == null || li.getPass() == null || li.getMail().equals("") || li.getPass().equals("")) {
throw new IllegalArgumentException("\83\81\81[\83\8b\83A\83h\83\8c\83X\82©\83p\83X\83\8f\81[\83h\82ª\8bó\94\92\82Å\82·\81B");
}
- if (li.isUseProxy() && (li.getProxy() == null || li.getProxy().length() <= 0) && (li.getPort() < 0
- || li.getPort() > 65535)) {
- throw new IllegalArgumentException("\83v\83\8d\83L\83V\82Ì\90Ý\92è\82ª\95s\90³\82Å\82·\81B");
- }
- String proxy;
+ String host;
int port;
- if (li.isUseProxy()) {
- proxy = li.getProxy();
- port = li.getPort();
+ if (li.getProxy() != Proxy.NO_PROXY) {
+ host = li.getProxy().getHost();
+ port = li.getProxy().getPort();
} else {
- proxy = null;
+ host = null;
port = -1;
}
- client = new NicoClient(li.getMail(), li.getPass(), stopFlag, proxy, port);
+ client = new NicoClient(li.getMail(), li.getPass(), stopFlag, host, port);
if (!client.isLoggedIn()) {
throw new IOException("\83\8d\83O\83C\83\93\82É\8e¸\94s");
throw new IOException(tag + "\82Ì\8fî\95ñ\82Ì\8eæ\93¾\82É\8e¸\94s", ex);
}
- if (videoType.getFileType() == VideoSaveKind.SAVE) {
+ if (videoType.isDoanload()) {
setVideoFileGetter(new VideoFileWebGetter(client, videoInfo));
}
- if (Boolean.TRUE.equals(commentType.getFileType())) {
+ if (commentType.isDoanload()) {
setCommentFileGetter(new CommentFileWebGetter(client, videoInfo, commentType.isAutoCommentNum(),
commentType.getBackComment()));
}
- if (Boolean.TRUE.equals(tcommType.getFileType())) {
+ if (tcommType.isDoanload()) {
setTcommFileGetter(new TcommFileWebGetter(client, videoInfo));
}
}
+ /**
+ * \93®\89æ\82Ì\83^\83C\83g\83\8b\82ð\8eæ\93¾\82·\82é\81B
+ * \8eÀ\8dÛ\82Ì\93®\89æ\83^\83C\83g\83\8b\82Í\83t\83@\83C\83\8b\96¼\82É\97p\82¢\82é\82±\82Æ\82ª\8fo\97\88\82È\82¢\95¶\8e\9a\82ð\8aÜ\82ñ\82Å\82 \82é\8fê\8d\87\82ª\82 \82é\82½\82ß\81A\83t\83@\83C\83\8b\96¼\82É\93K\8d\87\82·\82é\82æ\82¤\82É\95Ò\8fW\82µ\82½\92l\82ª\95Ô\82é\81B
+ * @return
+ */
@Override
public String getVideoTitle() {
- return videoInfo.getVideoTitle();
+ String name = videoInfo.getVideoTitle().replaceAll("[\\\\/:*?\"<>|.]", "_");
+ name = name.replaceAll("\u2212", "\81|"); // minus sign
+ name = name.replaceAll("\u301c", "\81`"); // wave dash
+ name = name.replaceAll("\u223c", "\81`"); // tilde operator
+ return name;
}
}
+++ /dev/null
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package saccubus.filegetter;
-
-import java.io.File;
-
-/**
- *
- * @author yuki
- */
-class FileLocator {
-
- private final boolean autoFileName;
- private final File initFile;
- private final String prefix;
- private final String title;
- private final String suffix;
-
- FileLocator(boolean autoFileName, File initFile, String prefix, String title, String suffix) {
- this.autoFileName = autoFileName;
- this.initFile = initFile;
- this.prefix = prefix;
- this.title = title;
- this.suffix = suffix;
- }
-
- File getFile() {
- if (!isAutoNaming()) {
- return initFile;
- } else {
- return new File(initFile, prefix + title + suffix);
- }
- }
-
- protected boolean isAutoNaming() {
- return autoFileName;
- }
-
- protected final boolean getAutoFileName() {
- return autoFileName;
- }
-}
+++ /dev/null
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package saccubus.filegetter;
-
-import java.io.File;
-import saccubus.VideoSaveKind;
-
-/**
- *
- * @author yuki
- */
-public class VideoFileLocator extends FileLocator {
-
- private final VideoSaveKind kind;
-
- public VideoFileLocator(VideoSaveKind kind, boolean autoFileName, File initFile, String prefix, String title,
- String suffix) {
- super(autoFileName, initFile, prefix, title, suffix);
- this.kind = kind;
- }
-
- @Override
- protected boolean isAutoNaming() {
- if (kind == VideoSaveKind.NICOBROWSER || !getAutoFileName()) {
- return false;
- }
- return true;
- }
-}
import saccubus.ConvertStopFlag;
import saccubus.ConvertStopFlag.State;
-import saccubus.Converter;
-import saccubus.ConvertingSetting;
+import saccubus.converter.Converter;
+import saccubus.properties.SProperties;
import saccubus.net.TextProgressListener;
/**
String pass = args[1];
String tag = args[2];
String time = args.length < 4 ? "" : args[3];
- ConvertingSetting setting = ConvertingSetting.loadSetting(mail, pass);
- Converter conv = new Converter(tag, time, setting, sl, new ConvertStopFlag(scl));
+ SProperties setting = SProperties.loadSetting(mail, pass);
+ Converter conv = new Converter(tag, time, setting.toProfile(), sl, new ConvertStopFlag(scl));
System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
System.out.println("Saccubus on CUI");
System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
--- /dev/null
+/* $Id$ */
+package saccubus.properties;
+
+import java.util.Properties;
+
+/**
+ * \8aî\96{\90Ý\92è.
+ * @author yuki
+ */
+public class BasicSetting {
+
+ private static final String PROP_MAILADDR = "MailAddress";
+ private static final String PROP_PASSWORD = "Password";
+ 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 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.proxyUse = proxyUse;
+ this.proxyHost = proxyHost;
+ this.proxyPort = proxyPort;
+ }
+
+ public String getMail() {
+ return mail;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getProxyHost() {
+ return proxyHost;
+ }
+
+ public int getProxyPort() {
+ return proxyPort;
+ }
+
+ public boolean isProxyUse() {
+ return proxyUse;
+ }
+
+ public void save(Properties prop) {
+ prop.setProperty(PROP_MAILADDR, getMail());
+ prop.setProperty(PROP_PASSWORD, getPassword());
+ prop.setProperty(PROP_USE_PROXY, Boolean.toString(isProxyUse()));
+ prop.setProperty(PROP_PROXY, getProxyHost());
+ prop.setProperty(PROP_PROXY_PORT, Integer.toString(getProxyPort()));
+ }
+
+ public static BasicSetting load(Properties prop, String user, String pass) {
+ if (user == null) {
+ user = prop.getProperty(PROP_MAILADDR, "");
+ }
+ if (pass == null) {
+ pass = prop.getProperty(PROP_PASSWORD, "");
+ }
+ boolean proxyUse = Boolean.parseBoolean(prop.getProperty(PROP_USE_PROXY, "false"));
+ String proxyHost = prop.getProperty(PROP_PROXY, "");
+ int proxyPort = Integer.parseInt(prop.getProperty(PROP_PROXY_PORT, "-1"));
+
+ return new BasicSetting(user, pass, proxyUse, proxyHost, proxyPort);
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.properties;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * \95Ï\8a·\90Ý\92è.
+ * @author yuki
+ */
+public class ConvertSetting {
+
+ private static final String PROP_DISABLE_VHOOK = "VhookDisabled";
+ private static final String PROP_SHOW_COMMENT = "ShowCommentNum";
+ private static final String PROP_FONT_PATH = "FontPath";
+ private static final String PROP_FONT_INDEX = "FontIndex";
+ private static final String PROP_SHADOW_INDEX = "ShadowIndex";
+ private static final String PROP_SHOW_VIDEO = "ShowVideo";
+ private static final String PROP_FIX_FONT_SIZE = "FixFontSize";
+ private static final String PROP_OPAQUE_COMMENT = "OpaqueComment";
+ private static final String PROP_NG_WORD = "NG_Word";
+ private static final String PROP_NG_ID = "NG_ID";
+ 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 ConvertSetting(boolean vhookDisabled, int maxNumOfComment, File font, int fontIndex, int shadowIndex,
+ boolean showConverting, boolean selfAdjustFontSize, boolean commentOpaque, NgSetting ngSetting) {
+ this.vhookDisabled = vhookDisabled;
+ this.maxNumOfComment = maxNumOfComment;
+ this.font = font;
+ this.fontIndex = fontIndex;
+ this.shadowIndex = shadowIndex;
+ this.showConverting = showConverting;
+ this.selfAdjustFontSize = selfAdjustFontSize;
+ this.commentOpaque = commentOpaque;
+ this.ngSetting = ngSetting;
+ }
+
+ public boolean isCommentOpaque() {
+ return commentOpaque;
+ }
+
+ public File getFont() {
+ return font;
+ }
+
+ public int getFontIndex() {
+ return fontIndex;
+ }
+
+ public int getMaxNumOfComment() {
+ return maxNumOfComment;
+ }
+
+ public boolean isSelfAdjustFontSize() {
+ return selfAdjustFontSize;
+ }
+
+ public int getShadowIndex() {
+ return shadowIndex;
+ }
+
+ public boolean isShowConverting() {
+ return showConverting;
+ }
+
+ public boolean isVhookDisabled() {
+ return vhookDisabled;
+ }
+
+ public NgSetting getNgSetting() {
+ return ngSetting;
+ }
+
+ public void save(Properties prop) {
+ prop.setProperty(PROP_SHOW_COMMENT, Integer.toString(getMaxNumOfComment()));
+ prop.setProperty(PROP_FONT_PATH, getFont().getPath());
+ prop.setProperty(PROP_FONT_INDEX, Integer.toString(getFontIndex()));
+ prop.setProperty(PROP_SHOW_VIDEO, Boolean.toString(isShowConverting()));
+ prop.setProperty(PROP_NG_WORD, getNgSetting().getWord());
+ prop.setProperty(PROP_NG_ID, getNgSetting().getId());
+ prop.setProperty(PROP_FIX_FONT_SIZE, Boolean.toString(isSelfAdjustFontSize()));
+ prop.setProperty(PROP_OPAQUE_COMMENT, Boolean.toString(isCommentOpaque()));
+ prop.setProperty(PROP_DISABLE_VHOOK, Boolean.toString(isVhookDisabled()));
+ prop.setProperty(PROP_SHADOW_INDEX, Integer.toString(getShadowIndex()));
+ }
+
+ public static ConvertSetting load(Properties prop) {
+ String win_dir = System.getenv("windir");
+ if (!win_dir.endsWith("\\")) {
+ win_dir = win_dir + "\\";
+ }
+
+
+ int maxComment = Integer.parseInt(prop.getProperty(PROP_SHOW_COMMENT, "30"));
+ String font = prop.getProperty(PROP_FONT_PATH, win_dir + "Fonts\\msgothic.ttc");
+ int fontIndex = Integer.parseInt(prop.getProperty(PROP_FONT_INDEX, "1"));
+ boolean showConv = Boolean.parseBoolean(prop.getProperty(PROP_SHOW_VIDEO, "true"));
+ String ngWord = prop.getProperty(PROP_NG_WORD, "");
+ String ngId = prop.getProperty(PROP_NG_ID, "");
+ boolean adjustFont = Boolean.parseBoolean(prop.getProperty(PROP_FIX_FONT_SIZE, "true"));
+ boolean opaque = Boolean.parseBoolean(prop.getProperty(PROP_OPAQUE_COMMENT, "false"));
+ boolean vhookDisabled = Boolean.parseBoolean(prop.getProperty(PROP_DISABLE_VHOOK, "false"));
+ int shadowIndex = Integer.parseInt(prop.getProperty(PROP_SHADOW_INDEX, "1"));
+
+ 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;
+ }
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.properties;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * \93ü\97Í\83R\83\81\83\93\83g\90Ý\92è.
+ * @author yuki
+ */
+public class InputCommentSetting extends InputFileSetting<Boolean> {
+
+ private static final String PROP_COMMENT_FILE = "CommentFile";
+ private static final String PROP_BACK_COMMENT = "BackComment";
+ private static final String PROP_DEL_COMMENT_AFTER_CONV = "DeleteCommentAfterConv";
+ private static final String PROP_COMMENT_FIX_FILE_NAME = "CommentFixFileName";
+ private static final String PROP_COMMENT_FIX_FILE_NAME_FOLDER = "CommentFixFileNameFolder";
+ private static final String PROP_FIX_COMMENT_NUM = "FixCommentSize";
+ private static final String PROP_SAVE_COMMENT = "SaveCommentFile";
+ private final boolean selfAdjustNumOfComment;
+ private final int numOfComment;
+
+ public InputCommentSetting(boolean download, boolean autoNaming, File folder, File file, boolean deleteAfterConvert,
+ boolean adjust, int numOfCom) {
+ super(Boolean.valueOf(download), autoNaming, folder, file, deleteAfterConvert);
+ this.selfAdjustNumOfComment = adjust;
+ this.numOfComment = numOfCom;
+ }
+
+ public void save(Properties prop) {
+ prop.setProperty(PROP_COMMENT_FILE, getFile().getPath());
+ prop.setProperty(PROP_BACK_COMMENT, Integer.toString(getNumOfComment()));
+ prop.setProperty(PROP_DEL_COMMENT_AFTER_CONV, Boolean.toString(isDeleteAfterConvert()));
+ prop.setProperty(PROP_COMMENT_FIX_FILE_NAME, Boolean.toString(isAutoNaming()));
+ prop.setProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, getFolder().getPath());
+ prop.setProperty(PROP_FIX_COMMENT_NUM, Boolean.toString(isSelfAdjustNumOfComment()));
+ prop.setProperty(PROP_SAVE_COMMENT, getProcessKind().toString());
+
+ }
+
+ public static InputCommentSetting load(Properties prop) {
+
+ String file = prop.getProperty(PROP_COMMENT_FILE, ".\\comment.xml");
+ String numOfComment = prop.getProperty(PROP_BACK_COMMENT, "500");
+ boolean delete = Boolean.parseBoolean(prop.getProperty(PROP_DEL_COMMENT_AFTER_CONV, "false"));
+ boolean adjustNumOfComment = Boolean.parseBoolean(prop.getProperty(PROP_COMMENT_FIX_FILE_NAME, "true"));
+ String folder = prop.getProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, ".\\[out]comment\\");
+ boolean autoNaming = Boolean.parseBoolean(prop.getProperty(PROP_FIX_COMMENT_NUM, "true"));
+ boolean download = Boolean.parseBoolean(prop.getProperty(PROP_SAVE_COMMENT, "true"));
+
+ return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete,
+ adjustNumOfComment,
+ Integer.parseInt(numOfComment));
+ }
+
+ public final boolean isSelfAdjustNumOfComment() {
+ return selfAdjustNumOfComment;
+ }
+
+ public final int getNumOfComment() {
+ return numOfComment;
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.properties;
+
+import java.io.File;
+
+/**
+ * \93ü\97Í\83t\83@\83C\83\8b\90Ý\92è\82Ì\82½\82ß\82Ì\83X\81[\83p\83N\83\89\83X.
+ * @author yuki
+ */
+public abstract class InputFileSetting<T> extends ProcessFileSetting<T> {
+
+ private final boolean deleteAfterConvert;
+
+ /**
+ * \93ü\97Í\83t\83@\83C\83\8b\90Ý\92è\82Ì\82½\82ß\82Ì\83X\81[\83p\83N\83\89\83X.
+ * @param processKind \83_\83E\83\93\83\8d\81[\83h\82·\82é\82Ì\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 autoNaming \83t\83H\83\8b\83_\96¼\82Ì\82Ý\82ð\8ew\92è\82µ\82Ä\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\96½\96¼/\8e©\93®\8c\9f\8dõ\82·\82é\82Ì\82Å\82 \82ê\82Îtrue,
+ * \83t\83@\83C\83\8b\96¼\82Ü\82Å\8ew\92è\82·\82é\82Ì\82Å\82 \82ê\82Îfalse.
+ * @param folder \89æ\96Ê\82Å\93ü\97Í\82µ\82½\83t\83H\83\8b\83_\96¼. autoNaming\82ªtrue\82Ì\8fê\8d\87\82É\97p\82¢\82ç\82ê\82é.
+ * @param file \89æ\96Ê\82Å\93ü\97Í\82µ\82½\83t\83@\83C\83\8b\96¼. autoNaming\82ªfalse\82Ì\8fê\8d\87\82É\97p\82¢\82ç\82ê\82é.
+ * @param deleteAfterConvert \95Ï\8a·\8f\88\97\9d\8cã\82É\83t\83@\83C\83\8b\82ð\8dí\8f\9c\82·\82é\82Ì\82Å\82 \82ê\82Îtrue.
+ */
+ public InputFileSetting(T processKind, boolean autoNaming, File folder,
+ File file, boolean deleteAfterConvert) {
+ super(processKind, autoNaming, folder, file);
+ this.deleteAfterConvert = deleteAfterConvert;
+ }
+
+ public final boolean isDeleteAfterConvert() {
+ return deleteAfterConvert;
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.properties;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * \93\8a\8de\8eÒ\83R\83\81\83\93\83g\82É\8aÖ\82·\82é\90Ý\92è.
+ * @author yuki
+ */
+public class InputTcommentSetting extends InputFileSetting<Boolean> {
+
+ /**
+ * \81u\93ü\97Í\93\8a\8de\8eÒ\83R\83\81\83\93\83g\81v\83p\83l\83\8b\82Ì\90Ý\92è.
+ * @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\82É\82 \82é\83t\83@\83C\83\8b\82ð\97p\82¢\82é\82Ì\82Å\82 \82ê\82Îfalse.
+ * @param inputDirectory \83\86\81[\83U\82ª\81u\95Û\91¶\82·\82é\83t\83H\83\8b\83_\82ð\8ew\92è\82µ\81A\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\82Å\8c\88\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l.
+ * @param inputFile \83\86\81[\83U\82ª\81u\95Û\91¶\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l.
+ * @param delete \8f\88\97\9d\8fI\97¹\8cã\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Îfalse.
+ */
+ public InputTcommentSetting(boolean download, boolean autoFileName, String inputDirectory, String inputFile,
+ boolean delete) {
+ super(Boolean.valueOf(download), autoFileName, new File(inputDirectory), new File(inputFile), delete);
+ }
+
+ public static InputTcommentSetting load(Properties prop) {
+ String str;
+ str = prop.getProperty(PROP_DOWNLOAD, Boolean.toString(true));
+ boolean down = Boolean.valueOf(str);
+ str = prop.getProperty(PROP_DELETE, Boolean.toString(false));
+ boolean del = Boolean.valueOf(str);
+ str = prop.getProperty(PROP_AUTOFILENAME, Boolean.toString(true));
+ boolean naming = Boolean.valueOf(str);
+ String dir = prop.getProperty(PROP_DIRECTORYNAME, ".\\[out]tcomment");
+ String f = prop.getProperty(PROP_FILENAME, ".\\tcomment.xml");
+ return new InputTcommentSetting(down, naming, dir, f, del);
+ }
+
+ public void save(Properties prop) {
+ prop.setProperty(PROP_DOWNLOAD, getProcessKind().toString());
+ prop.setProperty(PROP_DELETE, getProcessKind().toString());
+ prop.setProperty(PROP_AUTOFILENAME, Boolean.toString(isAutoNaming()));
+ prop.setProperty(PROP_DIRECTORYNAME, getFolder().toString());
+ prop.setProperty(PROP_FILENAME, getFile().toString());
+ }
+ private static final String PROP_DOWNLOAD = "TCDownload";
+ private static final String PROP_DELETE = "TCDelete";
+ private static final String PROP_AUTOFILENAME = "TCAutoNaming";
+ private static final String PROP_DIRECTORYNAME = "TCDirectory";
+ private static final String PROP_FILENAME = "TCFileName";
+}
--- /dev/null
+/* $Id$ */
+package saccubus.properties;
+
+import java.io.File;
+import java.util.Properties;
+import saccubus.VideoSaveKind;
+
+/**
+ * \93ü\97Í\93®\89æ\90Ý\92è\82ð\95Û\8e\9d\82·\82é\83N\83\89\83X.
+ * @author yuki
+ */
+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";
+
+ public InputVideoSetting(VideoSaveKind download, boolean autoNaming, File folder,
+ File file, boolean deleteAfterConvert) {
+ super(download, autoNaming, folder, file, deleteAfterConvert);
+ }
+
+ public void save(Properties prop) {
+ prop.setProperty(PROP_SAVE_VIDEO, getProcessKind().toString());
+ prop.setProperty(PROP_VIDEO_FILE, getFile().getPath());
+ 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()));
+
+
+ }
+
+ public static InputVideoSetting load(Properties prop) {
+ final VideoSaveKind kind = convertVideoSaveKind(prop);
+ boolean autoNaming = Boolean.parseBoolean(prop.getProperty(PROP_VIDEO_FIX_FILE_NAME, "true"));
+ 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"));
+
+ return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete);
+ }
+
+ /** \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é. */
+ private static VideoSaveKind convertVideoSaveKind(Properties prop) {
+ VideoSaveKind kind;
+ String saveVideo = prop.getProperty(PROP_SAVE_VIDEO);
+ if (Boolean.toString(true).equals(saveVideo) || saveVideo == null) {
+ kind = VideoSaveKind.SAVE;
+ } else if (Boolean.toString(false).equals(saveVideo)) {
+ kind = VideoSaveKind.NO_SAVE;
+ } else {
+ kind = VideoSaveKind.valueOf(saveVideo);
+ }
+ return kind;
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.properties;
+
+import java.io.File;
+import java.util.Properties;
+import saccubus.converter.FfmpegOption;
+
+/**
+ * \93®\89æ\90Ý\92è.
+ * @author yuki
+ */
+public class MovieSetting {
+
+ private static final String PROP_FFMPEG_PATH = "FFnpegPath";
+ private static final String PROP_VHOOK_PATH = "VhookPath";
+ private static final String PROP_OPTION_FILE = "OptionFile";
+ private static final String PROP_CMDLINE_EXT = "CMD_EXT";
+ private static final String PROP_CMDLINE_MAIN = "CMD_MAIN";
+ private static final String PROP_CMDLINE_IN = "CMD_IN";
+ private static final String PROP_CMDLINE_OUT = "CMD_OUT";
+ private final File ffmpeg;
+ private final File vhook;
+ private final File optionFile;
+ private final FfmpegOption ffmpegOption;
+
+ public MovieSetting(File ffmpeg, File vhook, File optionFile, FfmpegOption ffmpegOption) {
+ this.ffmpeg = ffmpeg;
+ this.vhook = vhook;
+ this.optionFile = optionFile;
+ this.ffmpegOption = ffmpegOption;
+ }
+
+ public File getFfmpeg() {
+ return ffmpeg;
+ }
+
+ public File getVhook() {
+ return vhook;
+ }
+
+ public File getOptionFile() {
+ return optionFile;
+ }
+
+ public FfmpegOption getFfmpegOption() {
+ return ffmpegOption;
+ }
+
+ public void save(Properties prop) {
+ prop.setProperty(PROP_FFMPEG_PATH, getFfmpeg().getPath());
+ prop.setProperty(PROP_VHOOK_PATH, getVhook().getPath());
+ prop.setProperty(PROP_CMDLINE_EXT, getFfmpegOption().getExtOption());
+ prop.setProperty(PROP_CMDLINE_MAIN, getFfmpegOption().getMainOption());
+ prop.setProperty(PROP_CMDLINE_IN, getFfmpegOption().getInOption());
+ prop.setProperty(PROP_CMDLINE_OUT, getFfmpegOption().getOutOption());
+ if (getOptionFile() != null) {
+ prop.setProperty(PROP_OPTION_FILE, getOptionFile().getPath());
+ } else {
+ prop.remove(PROP_OPTION_FILE);
+ }
+ }
+
+ public static MovieSetting load(Properties prop) {
+ String name = prop.getProperty(PROP_OPTION_FILE);
+ File optionFile = null;
+ if (name != null) {
+ optionFile = new File(name);
+ }
+
+ String ffmpeg = prop.getProperty(PROP_FFMPEG_PATH, ".\\bin\\ffmpeg.exe");
+ String vhook = prop.getProperty(PROP_VHOOK_PATH, ".\\bin\\nicovideo.dll");
+ String ext = prop.getProperty(PROP_CMDLINE_EXT, "mp4");
+ String main = prop.getProperty(PROP_CMDLINE_MAIN, "");
+ String in = prop.getProperty(PROP_CMDLINE_IN, "");
+ String out = prop.getProperty(PROP_CMDLINE_OUT, "-f ipod");
+ FfmpegOption opt = new FfmpegOption(ext, main, in, out);
+
+ return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.properties;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * \8fo\97Í\83R\83\81\83\93\83g\95t\82«\93®\89æ\82É\8aÖ\82·\82é\90Ý\92è.
+ * @author yuki
+ */
+public class OutputVideoSetting extends ProcessFileSetting<Boolean> {
+
+ private static final String PROP_SAVE_CONVERTED = "SaveConvertedFile";
+ private static final String PROP_ADD_COMMENT = "AddComment";
+ private static final String PROP_ADD_TCOMMENT = "AddTcomment";
+ private static final String PROP_CONVERTED_FILE = "ConvertedFile";
+ private static final String PROP_NOT_ADD_VIDEOID_CONV = "NotAddVideoIDtoConverted";
+ private static final String PROP_CONV_FIX_FILE_NAME = "ConvFixFileName";
+ private static final String PROP_CONV_FIX_FILE_NAME_FOLDER = "ConvFixFileNameFolder";
+ private final boolean cutIdName;
+ private final boolean addComment;
+ private final boolean addTcomment;
+
+ /**
+ *
+ * @param processKind \95Ï\8a·\8f\88\97\9d\82ð\8ds\82¤\82Ì\82Å\82 \82ê\82Îtrue.
+ * @param cutIdName \8fo\97Í\96¼\82É\93®\89æID\82ð\82Â\82¯\82È\82¢\82Ì\82Å\82 \82ê\82Îtrue. autoNaming\82ªtrue\82Ì\8fê\8d\87\82É\97p\82¢\82ç\82ê\82é.
+ * @param addComment \95Ï\8a·\8f\88\97\9d\8e\9e, \83R\83\81\83\93\83g\82ð\95t\89Á\82·\82é\82Ì\82Å\82 \82ê\82Îtrue.
+ * @param addTcomment \95Ï\8a·\8f\88\97\9d\8e\9e, \93\8a\8de\8eÒ\83R\83\81\83\93\83g\82ð\95t\89Á\82·\82é\82Ì\82Å\82 \82ê\82Îtrue.
+ */
+ public OutputVideoSetting(boolean processKind, boolean autoNaming, File folder, File file, boolean cutIdName,
+ boolean addComment, boolean addTcomment) {
+ super(processKind, autoNaming, folder, file);
+ this.cutIdName = cutIdName;
+ this.addComment = addComment;
+ this.addTcomment = addTcomment;
+ }
+
+ @Override
+ public void save(Properties prop) {
+ prop.setProperty(PROP_SAVE_CONVERTED, Boolean.toString(getProcessKind()));
+ prop.setProperty(PROP_ADD_COMMENT, Boolean.toString(isAddComment()));
+ prop.setProperty(PROP_ADD_TCOMMENT, Boolean.toString(isAddTcomment()));
+ prop.setProperty(PROP_CONVERTED_FILE, getFile().getPath());
+ prop.setProperty(PROP_NOT_ADD_VIDEOID_CONV, Boolean.toString(isCutIdName()));
+ prop.setProperty(PROP_CONV_FIX_FILE_NAME, (new Boolean(isAutoNaming())).toString());
+ prop.setProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, getFolder().getPath());
+
+
+ }
+
+ public static OutputVideoSetting load(Properties prop) {
+ boolean process = Boolean.parseBoolean(prop.getProperty(PROP_SAVE_CONVERTED, "true"));
+ boolean addComment = Boolean.valueOf(prop.getProperty(PROP_ADD_COMMENT, "true"));
+ boolean addTcomment = Boolean.valueOf(prop.getProperty(PROP_ADD_TCOMMENT, "true"));
+ String file = prop.getProperty(PROP_CONVERTED_FILE, ".\\video.avi");
+ boolean cutId = Boolean.parseBoolean(prop.getProperty(PROP_NOT_ADD_VIDEOID_CONV, "false"));
+ boolean autoNaming = Boolean.parseBoolean(prop.getProperty(PROP_CONV_FIX_FILE_NAME, "true"));
+ String folder = prop.getProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, ".\\[out]converted\\");
+
+ return new OutputVideoSetting(process, autoNaming, new File(folder), new File(file), cutId, addComment,
+ addTcomment);
+ }
+
+ public final boolean isCutIdName() {
+ return cutIdName;
+ }
+
+ public final boolean isAddComment() {
+ return addComment;
+ }
+
+ public final boolean isAddTcomment() {
+ return addTcomment;
+ }
+}
--- /dev/null
+/* $Id$ */
+package saccubus.properties;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * \8f\88\97\9d\91Î\8fÛ\83t\83@\83C\83\8b\90Ý\92è\82Ì\82½\82ß\82Ì\83X\81[\83p\83N\83\89\83X.
+ * @author yuki
+ */
+public abstract class ProcessFileSetting<T> {
+
+ private final T processKind;
+ private final boolean autoNaming;
+ private final File folder;
+ private final File file;
+
+ /**
+ * \8f\88\97\9d\91Î\8fÛ\83t\83@\83C\83\8b\90Ý\92è\82Ì\82½\82ß\82Ì\83X\81[\83p\83N\83\89\83X.
+ * @param processKind \8f\88\97\9d\82·\82é\8eí\97Þ\82ð\90Ý\92è\82·\82é.
+ * \91Î\8fÛ\83t\83@\83C\83\8b\82É\82æ\82è\88Ó\96¡\82Í\88Ù\82È\82é\82ª, \93ü\97Í\83t\83@\83C\83\8b\82Å\82Í\83_\83E\83\93\83\8d\81[\83h\82·\82é\82Ì\82Å\82 \82ê\82Îtrue,
+ * \8fo\97Í\83t\83@\83C\83\8b\82Å\82 \82ê\82Î\95Ï\8a·\82·\82é(\8fo\97Í\82·\82é)\82Ì\82Å\82 \82ê\82Îtrue, \82Æ\82¢\82¤\82æ\82¤\82É\97p\82¢\82é.
+ * @param autoNaming \83t\83H\83\8b\83_\96¼\82Ì\82Ý\82ð\8ew\92è\82µ\82Ä\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\96½\96¼/\8e©\93®\8c\9f\8dõ\82·\82é\82Ì\82Å\82 \82ê\82Îtrue,
+ * \83t\83@\83C\83\8b\96¼\82Ü\82Å\8ew\92è\82·\82é\82Ì\82Å\82 \82ê\82Îfalse.
+ * @param folder \89æ\96Ê\82Å\93ü\97Í\82µ\82½\83t\83H\83\8b\83_\96¼. autoNaming\82ªtrue\82Ì\8fê\8d\87\82É\97p\82¢\82ç\82ê\82é.
+ * @param file \89æ\96Ê\82Å\93ü\97Í\82µ\82½\83t\83@\83C\83\8b\96¼. autoNaming\82ªfalse\82Ì\8fê\8d\87\82É\97p\82¢\82ç\82ê\82é.
+ */
+ public ProcessFileSetting(T processKind, boolean autoNaming, File folder, File file) {
+ this.processKind = processKind;
+ this.autoNaming = autoNaming;
+ this.folder = folder;
+ this.file = file;
+ }
+
+ public final T getProcessKind() {
+ return processKind;
+ }
+
+ /**
+ * @return \81u\95Û\91¶\82·\82é\83t\83H\83\8b\83_\82ð\8ew\92è\82µ\81A\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\82Å\8c\88\92è\82·\82é\81v\82Ì\82Å\82 \82ê\82Îtrue.
+ * \81u\95Û\91¶\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é\81v\82Ì\82Å\82 \82ê\82Îfalse.
+ */
+ public final boolean isAutoNaming() {
+ return autoNaming;
+ }
+
+ public final File getFolder() {
+ return folder;
+ }
+
+ public final File getFile() {
+ return file;
+ }
+
+
+ public abstract void save(Properties prop);
+}
--- /dev/null
+package saccubus.properties;
+
+import java.util.Properties;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import saccubus.converter.Profile;
+
+/**
+ * <p>
+ * \83^\83C\83g\83\8b: \82³\82«\82ã\82Î\82·
+ * </p>
+ *
+ * <p>
+ * \90à\96¾: \83j\83R\83j\83R\93®\89æ\82Ì\93®\89æ\82ð\83R\83\81\83\93\83g\82Â\82«\82Å\95Û\91¶
+ * </p>
+ *
+ * <p>
+ * \92\98\8dì\8c : Copyright (c) 2007 PSI
+ * </p>
+ *
+ * <p>
+ * \89ï\8eÐ\96¼:
+ * </p>
+ *
+ * @author \96¢\93ü\97Í
+ * @version 1.0
+ */
+public class SProperties {
+
+ public static final String[] ShadowKindArray = {
+ "00:\82È\82µ",
+ "01:\83j\83R\83j\83R\93®\89æ\95\97",
+ "02:\89E\89º",
+ "03:\88Í\82¢\8d\9e\82Ý"
+ };
+ private final BasicSetting basicSetting;
+ private final InputVideoSetting inputVideoSetting;
+ private final InputCommentSetting inputCommentSetting;
+ private final InputTcommentSetting inputTcommentSetting;
+ private final OutputVideoSetting outputVideoSetting;
+ private final MovieSetting movieSetting;
+ private final ConvertSetting convertSetting;
+
+ public SProperties(
+ BasicSetting basicSetting,
+ InputVideoSetting inputVideoSetting,
+ InputCommentSetting inputCommentSetting,
+ InputTcommentSetting tcommentSetting,
+ OutputVideoSetting outputVideoSetting,
+ MovieSetting movieSetting,
+ ConvertSetting convertSetting // String videoshownum,
+ ) {
+// this.saveVideo = savevideo;
+// if (videofile.lastIndexOf(".") < videofile.lastIndexOf("\\")) {
+// videofile += ".flv";
+// }
+// VideoFile = new File(videofile);
+
+// if (commentfile.lastIndexOf(".") < commentfile.lastIndexOf("\\")) {
+// commentfile += ".xml";
+// }
+// CommentFile = new File(commentfile);
+
+// if (convvideofile.lastIndexOf(".") < convvideofile.lastIndexOf("\\")) {
+// convvideofile += ".avi";
+// }
+
+ this.basicSetting = basicSetting;
+ this.inputVideoSetting = inputVideoSetting;
+ this.inputCommentSetting = inputCommentSetting;
+ this.inputTcommentSetting = tcommentSetting;
+ this.outputVideoSetting = outputVideoSetting;
+ this.movieSetting = movieSetting;
+ this.convertSetting = convertSetting;
+ }
+
+ public Profile toProfile() {
+ // TODO toProfile\8eÀ\91\95.
+ throw new UnsupportedOperationException();
+ }
+ private static final String PROP_FILE = "./saccubus.xml";
+
+ public static void saveSetting(SProperties setting) {
+ final Properties prop = new Properties();
+ setting.getBasicSetting().save(prop);
+ setting.getInputVideoSetting().save(prop);
+ setting.getInputCommentSetting().save(prop);
+ setting.getInputTcommentSetting().save(prop);
+ setting.getOutputVideoSetting().save(prop);
+ setting.getMovieSetting().save(prop);
+ try {
+ prop.storeToXML(new FileOutputStream(PROP_FILE), "settings");
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public static SProperties loadSetting(String user, String password) {
+ Properties prop = new Properties();
+ try {
+ prop.loadFromXML(new FileInputStream(PROP_FILE));
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ return new SProperties(
+ BasicSetting.load(prop, user, password),
+ InputVideoSetting.load(prop),
+ InputCommentSetting.load(prop),
+ InputTcommentSetting.load(prop),
+ OutputVideoSetting.load(prop),
+ MovieSetting.load(prop),
+ ConvertSetting.load(prop));
+ }
+
+ public BasicSetting getBasicSetting() {
+ return basicSetting;
+ }
+
+ public InputVideoSetting getInputVideoSetting() {
+ return inputVideoSetting;
+ }
+
+ public InputCommentSetting getInputCommentSetting() {
+ return inputCommentSetting;
+ }
+
+ public InputTcommentSetting getInputTcommentSetting() {
+ return inputTcommentSetting;
+ }
+
+ public OutputVideoSetting getOutputVideoSetting() {
+ return outputVideoSetting;
+ }
+
+ public MovieSetting getMovieSetting() {
+ return movieSetting;
+ }
+
+ public ConvertSetting getConvertSetting() {
+ return convertSetting;
+ }
+}