package yukihane.inqubus.config;
import java.io.File;
-import java.lang.reflect.Field;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
public enum Properties {
INSTANCE;
- private final XMLConfiguration config;
- /** ニコニコ動画ログインID */
- private String p_nicovideo_id;
- /** ニコニコ動画ログインパスワード */
- private String p_nicovideo_password;
- /** プロキシを使用する */
- private String p_proxy_use;
- /** プロキシホスト */
- private String p_proxy_host;
- /** プロキシポート */
- private String p_proxy_port;
- /** NicoBrowser情報を参照する */
- private String p_nicobrowser_use;
- /** NicoBrowser DB ディレクトリ */
- private String p_nicobrowser_dblocation;
- /** 動画をダウンロードする */
- private String p_movie_download;
- /** 動画ダウンロードディレクトリ */
- private String p_movie_directory;
- /** コメントをダウンロードする */
- private String p_comment_download;
- /** コメントダウンロードディレクトリ */
- private String p_comment_directory;
- /** 投稿者コメントをダウンロードする */
- private String p_ownercomment_download;
- /** 投稿者コメントダウンロードディレクトリ */
- private String p_ownercomment_directory;
+ private final XMLConfiguration config = new XMLConfiguration();
- public boolean isOwnerCommentDownload() {
- return Boolean.valueOf(p_ownercomment_download);
+ public String getId() {
+ return config.getString("network.account.id", "");
}
- public void setOwnerCommentDownload(boolean download) {
- p_ownercomment_download = Boolean.toString(download);
+ /*
+ * ネットワーク - アカウント
+ */
+ public void setId(String s) {
+ config.setProperty("network.account.id", s);
}
- public boolean isCommentDownload() {
- return Boolean.valueOf(p_comment_download);
+ public String getPassword() {
+ return config.getString("network.account.password", "");
}
- public void setCommentDownload(boolean download) {
- p_comment_download = Boolean.toString(download);
+ public void setPassword(String s) {
+ config.setProperty("network.account.password", s);
}
- public File getMovieDirectory() {
- // TODO return new File(p_movie_directory);
- return new File("out/movie");
+ /*
+ * ネットワーク - プロキシ
+ */
+ public boolean getUseProxy() {
+ return config.getBoolean("network.proxy.use", false);
}
- public File getCommentDirectory() {
- // TODO
- return new File("out/comment");
+ public void setUseProxy(boolean s) {
+ config.setProperty("network.proxy.use", s);
}
- public void setMovieDirectory(String dir) {
- this.p_movie_directory = dir;
+ public String getProxyHost() {
+ return config.getString("network.proxy.host", "");
}
- public boolean isMovieDownload() {
- return Boolean.valueOf(p_movie_download);
+ public void setProxyHost(String s) {
+ config.setProperty("network.proxy.host", s);
}
- public void setMovieDownload(boolean download) {
- this.p_movie_download = Boolean.toString(download);
+ /*
+ * ファイル - 動画
+ */
+ public File getVideoDir() {
+ return new File(config.getString("file.video.dir", "in/video"));
}
- public String getDbLocation() {
- return p_nicobrowser_dblocation;
+ public void setVideoDir(File s) {
+ config.setProperty("file.video.dir", s.toString());
}
- public void setDbLocation(String p_nicobrowser_dblocation) {
- this.p_nicobrowser_dblocation = p_nicobrowser_dblocation;
+ public String getVideoFileNamePattern() {
+ return config.getString("file.video.filename", "[{id}]{title}");
}
- public boolean isDbUse() {
- return Boolean.valueOf(p_nicobrowser_use);
+ public void setVideoFileNamePattern(String s) {
+ config.setProperty("file.video.filename", s.toString());
}
- public void setDbUse(boolean use) {
- this.p_nicobrowser_use = Boolean.toString(use);
+ public boolean getVideoUseLocal() {
+ return config.getBoolean("file.video.local", false);
}
- public String getNicoVideoId() {
- return p_nicovideo_id;
+ public void setVideoUseLocal(boolean s) {
+ config.setProperty("file.video.local", s);
}
- public void setNicoVideoId(String id) {
- this.p_nicovideo_id = id;
+ /*
+ * ファイル - コメント
+ */
+ private static final String FILE_COMMENT_DIR = "file.comment.dir";
+
+ public File getCommentDir() {
+ return new File(config.getString(FILE_COMMENT_DIR, "in/comment"));
}
- public String getNicoVideoPassword() {
- return p_nicovideo_password;
+ public void setCommentDir(File s) {
+ config.setProperty(FILE_COMMENT_DIR, s.toString());
}
+ private static final String FILE_COMMENT_FILENAME = "file.comment.filename";
- public void setNicoVideoPassword(String password) {
- this.p_nicovideo_password = password;
+ public String getCommentFileNamePattern() {
+ return config.getString(FILE_COMMENT_FILENAME, "[{id}]{title}");
}
- public String getProxyHost() {
- return p_proxy_host;
+ public void setCommentFileNamePattern(String s) {
+ config.setProperty(FILE_COMMENT_FILENAME, s.toString());
}
+ private static final String FILE_COMMENT_LOCAL = "file.comment.local";
- public void setProxyHost(String host) {
- this.p_proxy_host = host;
+ public boolean getCommentUseLocal() {
+ return config.getBoolean(FILE_COMMENT_LOCAL, false);
}
- public int getP_proxy_port() {
- return Integer.parseInt(p_proxy_port);
+ public void setCommentUseLocal(boolean s) {
+ config.setProperty(FILE_COMMENT_LOCAL, s);
}
- public void setP_proxy_port(int port) {
- this.p_proxy_port = Integer.toString(port);
+ /*
+ * ファイル - 変換動画
+ */
+ private static final String FILE_OUTPUT_DIR = "file.output.dir";
+
+ public File getOutputDir() {
+ return new File(config.getString(FILE_OUTPUT_DIR, "out"));
}
- public boolean isProxyUse() {
- return Boolean.valueOf(p_proxy_use);
+ public void setOutputDir(File s) {
+ config.setProperty(FILE_OUTPUT_DIR, s.toString());
}
+ private static final String FILE_OUTPUT_FILENAME = "file.output.filename";
- public void setProxyUse(boolean use) {
- this.p_proxy_use = Boolean.toString(use);
+ public String getOutputFileNamePattern() {
+ return config.getString(FILE_OUTPUT_FILENAME, "{filename}");
}
- private String getPrefix() {
- return "p_";
+ public void setOutputFileNamePattern(String s) {
+ config.setProperty(FILE_OUTPUT_FILENAME, s.toString());
}
+ private static final String FILE_OUTPUT_ENABLE = "file.output.enable";
- private Properties() {
- config = new XMLConfiguration();
+ public boolean getOutputEnable() {
+ return config.getBoolean(FILE_OUTPUT_ENABLE, true);
}
- public void load(String fileName) throws ConfigurationException {
- config.setFileName(fileName);
- config.load();
+ public void setOutputEnable(boolean s) {
+ config.setProperty(FILE_OUTPUT_ENABLE, s);
}
+ private static final String FILE_OUTPUT_COMMENT_OVERLAY = "file.output.comment_overlay";
- public void save() throws ConfigurationException {
- try {
- final Class<? extends Properties> clazz = this.getClass();
- final Field[] fields = clazz.getDeclaredFields();
- final Field[] propertyFields = getPropertyFields(fields);
- for (Field f : propertyFields) {
- config.setProperty(getPropertyName(f), getPropertyValue(f));
- }
- config.save();
- } catch (Exception ex) {
- throw new ConfigurationException(ex);
- }
+ public boolean getOutputCommentOverlay() {
+ return config.getBoolean(FILE_OUTPUT_COMMENT_OVERLAY, true);
+ }
+
+ public void setOutputCommentOverlay(boolean s) {
+ config.setProperty(FILE_OUTPUT_COMMENT_OVERLAY, s);
+ }
+ private static final String FILE_OUTPUT_DISPLAY_PROGRESS = "file.output.display";
+
+ public boolean getOutputDisplayProgress() {
+ return config.getBoolean(FILE_OUTPUT_DISPLAY_PROGRESS, true);
+ }
+
+ public void setOutputDisplayProgress(boolean s) {
+ config.setProperty(FILE_OUTPUT_DISPLAY_PROGRESS, s);
+ }
+ /**
+ * コメント
+ */
+ private static final String COMMENT_SIZE_AUTOSIZE = "comment.size.autosize";
+
+ public boolean getCommentSizeAutosize() {
+ return config.getBoolean(COMMENT_SIZE_AUTOSIZE, true);
+ }
+
+ public void setCommentSizeAutosize(boolean s) {
+ config.setProperty(COMMENT_SIZE_AUTOSIZE, s);
+ }
+ private static final String COMMENT_SIZE_MANUAL = "comment.size.manual";
+
+ public Integer getCommentSizeManual() {
+ return config.getInteger(COMMENT_SIZE_MANUAL, null);
+ }
+
+ public void setCommentSizeManual(Integer s) {
+ config.setProperty(COMMENT_SIZE_MANUAL, s);
+ }
+ private static final String COMMENT_MIN_SIZE_AUTOSIZE = "comment.minutesize.autosize";
+
+ public boolean getCommentMinSizeAutosize() {
+ return config.getBoolean(COMMENT_MIN_SIZE_AUTOSIZE, true);
+ }
+
+ public void setCommentMinSizeAutosize(boolean s) {
+ config.setProperty(COMMENT_MIN_SIZE_AUTOSIZE, s);
+ }
+ private static final String COMMENT_MIN_SIZE_MANUAL = "comment.minutesize.manual";
+
+ public Integer getCommentMinSizeManual() {
+ return config.getInteger(COMMENT_MIN_SIZE_MANUAL, null);
}
- private Field[] getPropertyFields(Field[] fields) {
- List<Field> res = new ArrayList<Field>();
- for (Field f : fields) {
- if (f.getName().startsWith(getPrefix())) {
- res.add(f);
- }
- }
- return res.toArray(new Field[0]);
+ public void setCommentMinSizeManual(Integer s) {
+ config.setProperty(COMMENT_MIN_SIZE_MANUAL, s);
}
+ private static final String COMMENT_FONTPATH = "comment.fontpath";
- private String getPropertyName(Field field) {
- return field.getName().replace(getPrefix(), "").replace("_", ".");
+ public File getFontPath() {
+ return new File(config.getString(COMMENT_FONTPATH, "C:/Windows/Fonts/msgothic.ttc"));
}
- private String getPropertyValue(Field field) throws IllegalArgumentException, IllegalAccessException {
- field.setAccessible(true);
- return (String) field.get(this);
+ public void setFontPath(File s) {
+ config.setProperty(COMMENT_FONTPATH, s);
}
+ private static final String COMMENT_FONT_INDEX = "comment.fontindex";
- public boolean getUseMovieFileLocal() {
- // TODO
- return false;
+ public Integer getFontIndex() {
+ return config.getInteger(COMMENT_FONT_INDEX, Integer.valueOf(1));
}
- public boolean getCommentFileLocal() {
- // TODO
- return false;
+ public void setFontIndex(Integer s) {
+ config.setProperty(COMMENT_FONT_INDEX, s);
}
+ private static final String COMMENT_FONT_SHADOW = "comment.fontshadow";
- public boolean getOutputConvert() {
- // TODO
- return true;
+ public int getFontShadow() {
+ return config.getInt(COMMENT_FONT_SHADOW, 1);
}
- public String getFileNamePattern() {
- // TODO
- return "[{id}]{title}";
+ public void setFontIndex(int s) {
+ config.setProperty(COMMENT_FONT_SHADOW, s);
}
+ private static final String COMMENT_FONT_SIZING_DISABLE = "comment.font_no_sizing";
+
+ public boolean getFontSizeDisable() {
+ return config.getBoolean(COMMENT_FONT_SIZING_DISABLE, false);
+ }
+
+ public void setFontSizeDisable(boolean s) {
+ config.setProperty(COMMENT_FONT_SIZING_DISABLE, s);
+ }
+ private static final String COMMENT_FONT_OPAQUE = "comment.opaque";
+
+ public boolean getCommentOpaque() {
+ return config.getBoolean(COMMENT_FONT_OPAQUE, false);
+ }
+
+ public void setCommentOpaque(boolean s) {
+ config.setProperty(COMMENT_FONT_OPAQUE, s);
+ }
+
+ private static final String FFMPEG_PATH = "ffmpeg.path";
+
+ public File getFfmpegPath() {
+ return new File(config.getString(FFMPEG_PATH, "bin/ffmpeg.exe"));
+ }
+
+ public void setFfmpegPath(File s) {
+ config.setProperty(FFMPEG_PATH, s.toString());
+ }
+
+ private static final String FFMPEG_DLLPATH = "ffmpeg.dllpath";
+
+ public File getDllPath() {
+ return new File(config.getString(FFMPEG_DLLPATH, "bin/nicovideo.dll"));
+ }
+
+ public void setDllPath(File s) {
+ config.setProperty(FFMPEG_DLLPATH, s.toString());
+ }
+
+ /*
+ *
+ */
+ public void load(String fileName) throws ConfigurationException {
+ config.setFileName(fileName);
+ config.load();
+ }
+
+ public void save(File file) throws ConfigurationException {
+ config.setFile(file);
+ save();
+ }
+
+ public void save() throws ConfigurationException {
+ throw new UnsupportedOperationException();
+// try {
+// final Class<? extends Properties> clazz = this.getClass();
+// final Field[] fields = clazz.getDeclaredFields();
+// final Field[] propertyFields = getPropertyFields(fields);
+// for (Field f : propertyFields) {
+// config.setProperty(getPropertyName(f), getPropertyValue(f));
+// }
+// config.save();
+// } catch (SecurityException | IllegalArgumentException | IllegalAccessException | ConfigurationException ex) {
+// throw new ConfigurationException(ex);
+// }
+ }
+// private Field[] getPropertyFields(Field[] fields) {
+// List<Field> res = new ArrayList<Field>();
+// for (Field f : fields) {
+// if (f.getName().startsWith(getPrefix())) {
+// res.add(f);
+// }
+// }
+// return res.toArray(new Field[0]);
+// }
+//
+// private String getPropertyName(Field field) {
+// return field.getName().replace(getPrefix(), "").replace("_", ".");
+// }
+//
+// private String getPropertyValue(Field field) throws IllegalArgumentException, IllegalAccessException {
+// field.setAccessible(true);
+// return (String) field.get(this);
+// }
+//
+// public boolean getUseMovieFileLocal() {
+// // TODO
+// return false;
+// }
+//
+// public boolean getCommentFileLocal() {
+// // TODO
+// return false;
+// }
+//
+// public boolean getOutputConvert() {
+// // TODO
+// return true;
+// }
+//
+// public String getFileNamePattern() {
+// // TODO
+// return "[{id}]{title}";
+// }
}