OSDN Git Service

e21e87ece08a51f713fbf02438f1d7cd4e071c25
[coroid/inqubus.git] / frontend / src / saccubus / properties / InputVideoSetting.java
1 /* $Id$ */
2 package saccubus.properties;
3
4 import java.io.File;
5 import java.util.Properties;
6 import saccubus.VideoSaveKind;
7
8 /**
9  * \93ü\97Í\93®\89æ\90Ý\92è\82ð\95Û\8e\9d\82·\82é\83N\83\89\83X.
10  * @author yuki
11  */
12 public class InputVideoSetting extends InputFileSetting<VideoSaveKind> {
13
14     private static final String PROP_SAVE_VIDEO = "SaveVideoFile";
15     private static final String PROP_VIDEO_FIX_FILE_NAME = "VideoFixFileName";
16     private static final String PROP_VIDEO_FIX_FILE_NAME_FOLDER = "VideoFixFileNameFolder";
17     private static final String PROP_VIDEO_FILE = "VideoFile";
18     private static final String PROP_DEL_VIDEO_AFTER_CONV = "DeleteVideoAfterConv";
19     private static final String PROP_NICO_BROWSER_FILE_NAME = "NicoBrowserFileName";
20     private final File nicoBrowserFile;
21
22     public InputVideoSetting(VideoSaveKind download, boolean autoNaming, File folder,
23             File file, boolean deleteAfterConvert, File nicoBrowserFile) {
24         super(download, autoNaming, folder, file, deleteAfterConvert);
25         this.nicoBrowserFile = nicoBrowserFile;
26     }
27
28     public void save(Properties prop) {
29         prop.setProperty(PROP_SAVE_VIDEO, getProcessKind().toString());
30         prop.setProperty(PROP_VIDEO_FILE, getFile().getPath());
31         prop.setProperty(PROP_VIDEO_FIX_FILE_NAME, Boolean.toString(isAutoNaming()));
32         prop.setProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, getFolder().getPath());
33         prop.setProperty(PROP_DEL_VIDEO_AFTER_CONV, Boolean.toString(isDeleteAfterConvert()));
34         prop.setProperty(PROP_NICO_BROWSER_FILE_NAME, getNicoBrowserFile().getPath());
35     }
36
37     public static InputVideoSetting load(Properties prop) {
38         final VideoSaveKind kind = convertVideoSaveKind(prop);
39         boolean autoNaming = Boolean.parseBoolean(prop.getProperty(PROP_VIDEO_FIX_FILE_NAME, "true"));
40         String folder = prop.getProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, ".\\[out]video\\");
41         String file = prop.getProperty(PROP_VIDEO_FILE, ".\\video.flv");
42         boolean delete = Boolean.parseBoolean(prop.getProperty(PROP_DEL_VIDEO_AFTER_CONV, "false"));
43         String nibrFile = prop.getProperty(PROP_NICO_BROWSER_FILE_NAME, "");
44
45         return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
46     }
47
48     /** \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é. */
49     private static VideoSaveKind convertVideoSaveKind(Properties prop) {
50         VideoSaveKind kind;
51         String saveVideo = prop.getProperty(PROP_SAVE_VIDEO);
52         if (Boolean.toString(true).equals(saveVideo) || saveVideo == null) {
53             kind = VideoSaveKind.SAVE;
54         } else if (Boolean.toString(false).equals(saveVideo)) {
55             kind = VideoSaveKind.NO_SAVE;
56         } else {
57             kind = VideoSaveKind.valueOf(saveVideo);
58         }
59         return kind;
60     }
61
62     public File getNicoBrowserFile() {
63         return nicoBrowserFile;
64     }
65 }