3 import java.util.Properties;
4 import java.io.IOException;
5 import java.io.FileOutputStream;
6 import java.io.FileInputStream;
11 *
\83^
\83C
\83g
\83\8b:
\82³
\82«
\82ã
\82Î
\82·
15 *
\90à
\96¾:
\83j
\83R
\83j
\83R
\93®
\89æ
\82Ì
\93®
\89æ
\82ð
\83R
\83\81\83\93\83g
\82Â
\82«
\82Å
\95Û
\91¶
19 *
\92\98\8dì
\8c : Copyright (c) 2007 PSI
26 * @author
\96¢
\93ü
\97Í
29 public class ConvertingSetting {
30 public static final String[] ShadowKindArray = {
32 "01:
\83j
\83R
\83j
\83R
\93®
\89æ
\95\97",
34 "03:
\88Í
\82¢
\8d\9e\82Ý"
37 private String MailAddress;
39 private String Password;
41 private VideoSaveKind saveVideo;
43 private File VideoFile;
45 private boolean SaveComment;
47 private File CommentFile;
49 private boolean SaveConverted;
51 private File ConvertedVideoFile;
53 private String FFmpegPath;
55 private String VhookPath;
57 private String CmdLineOptionExt;
59 private String CmdLineOptionIn;
61 private String CmdLineOptionOut;
63 private String CmdLineOptionMain;
65 private String FontPath;
67 private int FontIndex;
69 private String BackComment;
71 private boolean Vhook_ShowConvertingVideo;
73 private int VideoShowNum;
75 private boolean DeleteVideoAfterConverting;
77 private boolean VideoFixFileName;
79 private File VideoFixFileNameFolder;
81 private boolean DeleteCommentAfterConverting;
83 private boolean CommentFixFileName;
85 private File CommentFixFileNameFolder;
87 private boolean ConvFixFileName;
89 private File ConvFixFileNameFolder;
91 private String NG_Word;
95 private boolean UseProxy;
99 private int ProxyPort;
101 private boolean FixFontSize;
103 private boolean FixCommentNum;
105 private boolean OpaqueComment;
107 private boolean NotAddVideoID_Conv;
109 private boolean UseOptionFile;
111 private File OptionFile;
113 private boolean DisableVhook;
115 private int ShadowIndex;
117 public ConvertingSetting(String mailaddress, String password,
118 VideoSaveKind savevideo, String videofile, boolean savecomment,
119 String commentfile, boolean saveconverted, String convvideofile,
120 String videoshownum, String ffmpegpath, String vhookpath,
121 String cmdlineoption_ext, String cmdlineoption_main,
122 String cmdlineoption_in, String cmdlineoption_out,
123 String backcomment, String fontpath, int font_index,
124 boolean showconvvideo, boolean delete_video_after_conv,
125 boolean video_fix_file_name, String video_fix_file_name_folder,
126 boolean delete_comment_after_conv, boolean comment_fix_file_name,
127 String comment_fix_file_name_folder, boolean not_add_videoid_conv,
128 boolean conv_fix_file_name, String conv_fix_file_name_folder,
129 String ngword, String ngid, boolean use_proxy, String proxy,
130 int proxy_port, boolean fix_font_size, boolean fix_comment_num,
131 boolean opaque_comment, File option_file, boolean disable_vhook,
133 MailAddress = mailaddress;
135 this.saveVideo = savevideo;
136 if (videofile.lastIndexOf(".") < videofile.lastIndexOf("\\")) {
139 VideoFile = new File(videofile);
140 SaveComment = savecomment;
141 if (commentfile.lastIndexOf(".") < commentfile.lastIndexOf("\\")) {
142 commentfile += ".xml";
144 CommentFile = new File(commentfile);
145 SaveConverted = saveconverted;
146 if (convvideofile.lastIndexOf(".") < convvideofile.lastIndexOf("\\")) {
147 convvideofile += ".avi";
149 ConvertedVideoFile = new File(convvideofile);
151 VideoShowNum = Integer.parseInt(videoshownum);
152 } catch (NumberFormatException ex) {
155 FFmpegPath = ffmpegpath;
156 VhookPath = vhookpath;
157 CmdLineOptionExt = cmdlineoption_ext;
158 CmdLineOptionMain = cmdlineoption_main;
159 CmdLineOptionIn = cmdlineoption_in;
160 CmdLineOptionOut = cmdlineoption_out;
161 BackComment = backcomment;
163 FontIndex = font_index;
164 Vhook_ShowConvertingVideo = showconvvideo;
165 DeleteVideoAfterConverting = delete_video_after_conv;
166 VideoFixFileName = video_fix_file_name;
167 VideoFixFileNameFolder = new File(video_fix_file_name_folder, "");
168 DeleteCommentAfterConverting = delete_comment_after_conv;
169 CommentFixFileName = comment_fix_file_name;
170 CommentFixFileNameFolder = new File(comment_fix_file_name_folder, "");
171 NotAddVideoID_Conv = not_add_videoid_conv;
172 ConvFixFileName = conv_fix_file_name;
173 ConvFixFileNameFolder = new File(conv_fix_file_name_folder, "");
176 UseProxy = use_proxy;
178 ProxyPort = proxy_port;
179 FixFontSize = fix_font_size;
180 FixCommentNum = fix_comment_num;
181 OpaqueComment = opaque_comment;
182 OptionFile = option_file;
183 DisableVhook = disable_vhook;
184 ShadowIndex = shadow_index;
187 public File getVideoFile() {
191 public File getCommentFile() {
195 public File getConvertedVideoFile() {
196 return ConvertedVideoFile;
199 public String getFFmpegPath() {
203 public String getVhookPath() {
207 public String getCmdLineOptionIn() {
208 return CmdLineOptionIn;
211 public String getFontPath() {
215 public String getFontIndex() {
216 return Integer.toString(FontIndex);
219 public boolean isVhook_ShowConvertingVideo() {
220 return Vhook_ShowConvertingVideo;
223 public String getMailAddress() {
227 public String getPassword() {
231 public VideoSaveKind getVideoSaveKind() {
235 public boolean isSaveComment() {
239 /** @return
\81u
\83R
\83\81\83\93\83g
\95t
\82«
\93®
\89æ
\82É
\95Ï
\8a·
\82·
\82é
\81v
\82È
\82çtrue. */
240 public boolean isSaveConverted() {
241 return SaveConverted;
244 public String getCmdLineOptionOut() {
245 return CmdLineOptionOut;
248 public String getBackComment() {
252 public String getVideoShowNum() {
253 return Integer.toString(VideoShowNum);
256 public String getCmdLineOptionExt() {
257 return CmdLineOptionExt;
260 public String getCmdLineOptionMain() {
261 return CmdLineOptionMain;
265 * @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.
266 *
\81u
\95Û
\91¶
\82·
\82é
\83t
\83@
\83C
\83\8b\96¼
\82ð
\8ew
\92è
\82·
\82é
\81v
\82Ì
\82Å
\82 \82ê
\82Îfalse.
268 public boolean isVideoFixFileName() {
269 return VideoFixFileName;
272 public boolean isDeleteVideoAfterConverting() {
273 return DeleteVideoAfterConverting;
276 public File getVideoFixFileNameFolder() {
277 return VideoFixFileNameFolder;
280 public boolean isCommentFixFileName() {
281 return CommentFixFileName;
284 public boolean isDeleteCommentAfterConverting() {
285 return DeleteCommentAfterConverting;
288 public File getCommentFixFileNameFolder() {
289 return CommentFixFileNameFolder;
292 public boolean isNotAddVideoID_Conv() {
293 return NotAddVideoID_Conv;
296 public boolean isConvFixFileName() {
297 return ConvFixFileName;
300 public File getConvFixFileNameFolder() {
301 return ConvFixFileNameFolder;
304 public String getNG_Word() {
308 public String getNG_ID() {
312 public boolean useProxy() {
316 public String getProxy() {
320 public int getProxyPort() {
324 public boolean isFixFontSize() {
328 public boolean isFixCommentNum() {
329 return FixCommentNum;
332 public boolean isOpaqueComment() {
333 return OpaqueComment;
336 public boolean useOptionFile() {
337 return UseOptionFile;
340 public File getOptionFile() {
344 public boolean isVhookDisabled() {
347 public int getShadowIndex(){
351 private static final String PROP_FILE = "./saccubus.xml";
353 private static final String PROP_MAILADDR = "MailAddress";
354 private static final String PROP_PASSWORD = "Password";
356 private static final String PROP_SAVE_VIDEO = "SaveVideoFile";
358 private static final String PROP_VIDEO_FILE = "VideoFile";
360 private static final String PROP_SAVE_COMMENT = "SaveCommentFile";
362 private static final String PROP_COMMENT_FILE = "CommentFile";
364 private static final String PROP_SAVE_CONVERTED = "SaveConvertedFile";
366 private static final String PROP_CONVERTED_FILE = "ConvertedFile";
368 private static final String PROP_FFMPEG_PATH = "FFnpegPath";
370 private static final String PROP_VHOOK_PATH = "VhookPath";
372 private static final String PROP_FONT_PATH = "FontPath";
374 private static final String PROP_FONT_INDEX = "FontIndex";
376 private static final String PROP_CMDLINE_EXT = "CMD_EXT";
378 private static final String PROP_CMDLINE_MAIN = "CMD_MAIN";
380 private static final String PROP_CMDLINE_IN = "CMD_IN";
382 private static final String PROP_CMDLINE_OUT = "CMD_OUT";
384 private static final String PROP_BACK_COMMENT = "BackComment";
386 private static final String PROP_SHOW_VIDEO = "ShowVideo";
388 private static final String PROP_SHOW_COMMENT = "ShowCommentNum";
390 private static final String PROP_VIDEO_FIX_FILE_NAME = "VideoFixFileName";
392 private static final String PROP_DEL_VIDEO_AFTER_CONV = "DeleteVideoAfterConv";
394 private static final String PROP_VIDEO_FIX_FILE_NAME_FOLDER = "VideoFixFileNameFolder";
396 private static final String PROP_DEL_COMMENT_AFTER_CONV = "DeleteCommentAfterConv";
398 private static final String PROP_COMMENT_FIX_FILE_NAME = "CommentFixFileName";
400 private static final String PROP_COMMENT_FIX_FILE_NAME_FOLDER = "CommentFixFileNameFolder";
402 private static final String PROP_NOT_ADD_VIDEOID_CONV = "NotAddVideoIDtoConverted";
404 private static final String PROP_CONV_FIX_FILE_NAME = "ConvFixFileName";
406 private static final String PROP_CONV_FIX_FILE_NAME_FOLDER = "ConvFixFileNameFolder";
408 private static final String PROP_NG_WORD = "NG_Word";
410 private static final String PROP_NG_ID = "NG_ID";
412 private static final String PROP_USE_PROXY = "UseProxy";
414 private static final String PROP_PROXY = "Proxy";
416 private static final String PROP_PROXY_PORT = "ProxyPort";
418 private static final String PROP_FIX_FONT_SIZE = "FixFontSize";
420 private static final String PROP_FIX_COMMENT_NUM = "FixCommentSize";
422 private static final String PROP_OPAQUE_COMMENT = "OpaqueComment";
424 private static final String PROP_OPTION_FILE = "OptionFile";
426 private static final String PROP_DISABLE_VHOOK = "VhookDisabled";
428 private static final String PROP_SHADOW_INDEX = "ShadowIndex";
430 public static void saveSetting(ConvertingSetting setting) {
431 Properties prop = new Properties();
432 prop.setProperty(PROP_MAILADDR, setting.getMailAddress());
433 prop.setProperty(PROP_PASSWORD, setting.getPassword());
434 prop.setProperty(PROP_SAVE_VIDEO, setting.getVideoSaveKind().toString());
435 prop.setProperty(PROP_VIDEO_FILE, setting.getVideoFile().getPath());
436 prop.setProperty(PROP_SAVE_COMMENT, Boolean.toString(setting
438 prop.setProperty(PROP_COMMENT_FILE, setting.getCommentFile().getPath());
439 prop.setProperty(PROP_SAVE_CONVERTED, Boolean.toString(setting
440 .isSaveConverted()));
441 prop.setProperty(PROP_SHOW_COMMENT, setting.getVideoShowNum());
442 prop.setProperty(PROP_CONVERTED_FILE, setting.getConvertedVideoFile()
444 prop.setProperty(PROP_FFMPEG_PATH, setting.getFFmpegPath());
445 prop.setProperty(PROP_VHOOK_PATH, setting.getVhookPath());
446 prop.setProperty(PROP_FONT_PATH, setting.getFontPath());
447 prop.setProperty(PROP_FONT_INDEX, setting.getFontIndex());
448 prop.setProperty(PROP_CMDLINE_EXT, setting.getCmdLineOptionExt());
449 prop.setProperty(PROP_CMDLINE_MAIN, setting.getCmdLineOptionMain());
450 prop.setProperty(PROP_CMDLINE_IN, setting.getCmdLineOptionIn());
451 prop.setProperty(PROP_CMDLINE_OUT, setting.getCmdLineOptionOut());
452 prop.setProperty(PROP_BACK_COMMENT, setting.getBackComment());
453 prop.setProperty(PROP_SHOW_VIDEO, Boolean.toString((setting
454 .isVhook_ShowConvertingVideo())));
455 prop.setProperty(PROP_DEL_VIDEO_AFTER_CONV, Boolean.toString(setting
456 .isDeleteVideoAfterConverting()));
457 prop.setProperty(PROP_VIDEO_FIX_FILE_NAME, Boolean.toString(setting
458 .isVideoFixFileName()));
459 prop.setProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, setting
460 .getVideoFixFileNameFolder().getPath());
461 prop.setProperty(PROP_DEL_COMMENT_AFTER_CONV, Boolean.toString(setting
462 .isDeleteCommentAfterConverting()));
463 prop.setProperty(PROP_COMMENT_FIX_FILE_NAME, Boolean.toString(setting
464 .isCommentFixFileName()));
465 prop.setProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, setting
466 .getCommentFixFileNameFolder().getPath());
468 prop.setProperty(PROP_NOT_ADD_VIDEOID_CONV, Boolean.toString(setting
469 .isNotAddVideoID_Conv()));
471 prop.setProperty(PROP_CONV_FIX_FILE_NAME, (new Boolean(setting
472 .isConvFixFileName())).toString());
473 prop.setProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, setting
474 .getConvFixFileNameFolder().getPath());
476 prop.setProperty(PROP_NG_WORD, setting.getNG_Word());
477 prop.setProperty(PROP_NG_ID, setting.getNG_ID());
478 prop.setProperty(PROP_USE_PROXY, Boolean.toString(setting.useProxy()));
479 prop.setProperty(PROP_PROXY, setting.getProxy());
480 prop.setProperty(PROP_PROXY_PORT, Integer.toString(setting
482 prop.setProperty(PROP_FIX_FONT_SIZE, Boolean.toString(setting
484 prop.setProperty(PROP_FIX_COMMENT_NUM, Boolean.toString(setting
485 .isFixCommentNum()));
486 prop.setProperty(PROP_OPAQUE_COMMENT, Boolean.toString(setting
487 .isOpaqueComment()));
488 if (setting.getOptionFile() != null) {
489 prop.setProperty(PROP_OPTION_FILE, setting.getOptionFile()
492 prop.setProperty(PROP_DISABLE_VHOOK, Boolean.toString(setting
493 .isVhookDisabled()));
494 prop.setProperty(PROP_SHADOW_INDEX, Integer.toString(setting.getShadowIndex()));
496 prop.storeToXML(new FileOutputStream(PROP_FILE), "settings");
497 } catch (IOException ex) {
498 ex.printStackTrace();
502 /**
\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é. */
503 private static VideoSaveKind convertVideoSaveKind(Properties prop) {
505 String saveVideo = prop.getProperty(PROP_SAVE_VIDEO);
506 if (Boolean.toString(true).equals(saveVideo) || saveVideo == null) {
507 kind = VideoSaveKind.SAVE;
508 } else if (Boolean.toString(false).equals(saveVideo)) {
509 kind = VideoSaveKind.NO_SAVE;
511 kind = VideoSaveKind.valueOf(saveVideo);
516 public static ConvertingSetting loadSetting(String user, String password) {
517 Properties prop = new Properties();
519 prop.loadFromXML(new FileInputStream(PROP_FILE));
520 } catch (IOException ex) {
521 ex.printStackTrace();
524 user = prop.getProperty(PROP_MAILADDR, "");
526 if (password == null) {
527 password = prop.getProperty(PROP_PASSWORD, "");
529 String option_file_name = prop.getProperty(PROP_OPTION_FILE, null);
530 File option_file = null;
531 if (option_file_name != null) {
532 option_file = new File(option_file_name);
534 String win_dir = System.getenv("windir");
535 if(!win_dir.endsWith("\\")){
536 win_dir = win_dir+"\\";
539 final VideoSaveKind kind = convertVideoSaveKind(prop);
540 return new ConvertingSetting(user, password,
542 prop.getProperty(PROP_VIDEO_FILE, ".\\video.flv"),
543 Boolean.parseBoolean(prop.getProperty(PROP_SAVE_COMMENT, "true")),
544 prop.getProperty(PROP_COMMENT_FILE, ".\\comment.xml"),
545 Boolean.parseBoolean(prop.getProperty(PROP_SAVE_CONVERTED, "true")),
546 prop.getProperty(PROP_CONVERTED_FILE, ".\\video.avi"),
547 prop.getProperty(PROP_SHOW_COMMENT, "30"),
548 prop.getProperty(PROP_FFMPEG_PATH,".\\bin\\ffmpeg.exe"),
549 prop.getProperty(PROP_VHOOK_PATH,".\\bin\\nicovideo.dll"),
550 prop.getProperty(PROP_CMDLINE_EXT, "avi"),
551 prop.getProperty(PROP_CMDLINE_MAIN,""),
552 prop.getProperty(PROP_CMDLINE_IN, ""),
553 prop.getProperty(PROP_CMDLINE_OUT,"-s 512x384 -acodec libmp3lame -ab 128k -ar 44100 -ac 2 -vcodec libxvid -qscale 3 -async 1"),
554 prop.getProperty(PROP_BACK_COMMENT, "500"),
555 prop.getProperty(PROP_FONT_PATH, win_dir+"Fonts\\msgothic.ttc"),
556 Integer.parseInt(prop.getProperty(PROP_FONT_INDEX, "1")),
557 Boolean.parseBoolean(prop.getProperty(PROP_SHOW_VIDEO, "true")),
558 Boolean.parseBoolean(prop.getProperty(PROP_DEL_VIDEO_AFTER_CONV, "false")),
559 Boolean.parseBoolean(prop.getProperty(PROP_VIDEO_FIX_FILE_NAME, "true")),
560 prop.getProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER,".\\[out]video\\"),
561 Boolean.parseBoolean(prop.getProperty(PROP_DEL_COMMENT_AFTER_CONV, "false")),
562 Boolean.parseBoolean(prop.getProperty(PROP_COMMENT_FIX_FILE_NAME, "true")),
563 prop.getProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, ".\\[out]comment\\"),
564 Boolean.parseBoolean(prop.getProperty(PROP_NOT_ADD_VIDEOID_CONV, "false")),
565 Boolean.parseBoolean(prop.getProperty(PROP_CONV_FIX_FILE_NAME,"true")),
566 prop.getProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, ".\\[out]converted\\"),
567 prop.getProperty(PROP_NG_WORD, ""),
568 prop.getProperty(PROP_NG_ID, ""),
569 Boolean.parseBoolean(prop.getProperty(PROP_USE_PROXY, "false")),
570 prop.getProperty(PROP_PROXY,""),
571 Integer.parseInt(prop.getProperty(PROP_PROXY_PORT,"-1")),
572 Boolean.parseBoolean(prop.getProperty(PROP_FIX_FONT_SIZE, "true")),
573 Boolean.parseBoolean(prop.getProperty(PROP_FIX_COMMENT_NUM, "true")),
574 Boolean.parseBoolean(prop.getProperty(PROP_OPAQUE_COMMENT,"false")),
575 option_file, Boolean.parseBoolean(prop.getProperty(PROP_DISABLE_VHOOK,"false")),
576 Integer.parseInt(prop.getProperty(PROP_SHADOW_INDEX,"1"),