private static final String lowPattern = "{low}";
private static Logger log = LoggerFactory.getLogger(NamePattern.class);
private final String pattern;
- private String replaceFrom = "";
- private String replaceTo = "";
private String id = "";
private String title = "";
private boolean isNotLow = true;
* @param replaceTo 禁則文字をこの文字列に置換する.
* @param title ファイル名に用いるタイトル文字列.
*/
- public NamePattern(String pattern, String replaceFrom, String replaceTo, String title) {
+ public NamePattern(String pattern, String title) {
this.pattern = pattern;
- this.replaceFrom = replaceFrom;
- this.replaceTo = replaceTo;
this.title = title;
}
this.isNotLow = isNotLow;
}
- public final void setReplaceFrom(String replaceFrom) {
- this.replaceFrom = replaceFrom;
- }
-
- public final void setReplaceTo(String replaceTo) {
- this.replaceTo = replaceTo;
- }
-
public final void setTitle(String title) {
this.title = title;
}
ProgressListener listener) throws IOException, URISyntaxException, HttpException, InterruptedException {
String file = FilenameUtils.getName(fileName);
String dir = fileName.substring(0, fileName.length() - file.length());
- NamePattern np = new NamePattern(file, "", "", "");
+ NamePattern np = new NamePattern(file, "");
return getFlvFile(vi, new File(dir), np, nowStatus, needLowFile, listener);
}
/*$Id$*/
package nicobrowser.config;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public static final String P_PATH_DB = "path.db";
public static final String P_PATH_SAVEFILE = "path.savefile";
public static final String P_SAVEFILE_PATTERN = "savefilename.pattern";
- public static final String P_SAVEFILE_REPLACE_FROM = "savefilename.replace.from";
- public static final String P_SAVEFILE_REPLACE_TO = "savefilename.replace.to";
public static final String P_FILE_ENCODING = "encoding";
public static final String P_NICOVIDEO_MAIL = "nicovideo.mail";
public static final String P_NICOVIDEO_PASSWORD = "nicovideo.password";
updatePropertyValue(p, P_PATH_DB);
updatePropertyValue(p, P_PATH_SAVEFILE);
updatePropertyValue(p, P_SAVEFILE_PATTERN);
- updatePropertyValue(p, P_SAVEFILE_REPLACE_FROM);
- updatePropertyValue(p, P_SAVEFILE_REPLACE_TO);
updatePropertyValue(p, P_DOWNLOAD_RETRY);
updatePropertyValue(p, P_DOWNLOAD_WAIT);
props.add(savepath);
props.add(P_SAVEFILE_PATTERN + "={title}");
- props.add(P_SAVEFILE_REPLACE_FROM + "=\\/\\\\:*?\\\"<>|.");
- props.add(P_SAVEFILE_REPLACE_TO + "=_");
props.add(P_FILE_ENCODING + "=" + System.getProperty("file.encoding"));
return properties.getString(P_SAVEFILE_PATTERN, "{title}");
}
- public String getFileNameReplaceFrom() {
- return properties.getString(P_SAVEFILE_REPLACE_FROM, "/\\:*?\"<>|.");
- }
-
- public String getFileNameReplaceTo() {
- return properties.getString(P_SAVEFILE_REPLACE_TO, "_");
- }
-
/** @return feedurl.txtの文字エンコーディング. */
public String getEncoding() {
String res = properties.getString(P_FILE_ENCODING, System.getProperty("file.encoding"));
-<?xml version="1.1" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel5" min="-2" max="-2" attributes="0"/>
- <EmptySpace min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<EmptySpace max="-2" attributes="0"/>
<Component id="namePatternField" pref="399" max="32767" attributes="0"/>
</Group>
- <Group type="102" alignment="0" attributes="0">
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="replaceToLabel" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="replaceFromLabel" alignment="0" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="replaceFromField" alignment="0" pref="371" max="32767" attributes="0"/>
- <Component id="replaceToField" alignment="0" pref="371" max="32767" attributes="0"/>
- </Group>
- </Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="namePatternScroll" min="-2" pref="71" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="3" attributes="0">
- <Component id="replaceFromLabel" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="replaceFromField" alignment="3" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="3" attributes="0">
- <Component id="replaceToLabel" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="replaceToField" alignment="3" min="-2" max="-2" attributes="0"/>
- </Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
<Property name="text" type="java.lang.String" value="命名規則"/>
</Properties>
</Component>
- <Component class="javax.swing.JLabel" name="replaceFromLabel">
- <Properties>
- <Property name="text" type="java.lang.String" value="置換対象文字"/>
- </Properties>
- </Component>
- <Component class="javax.swing.JLabel" name="replaceToLabel">
- <Properties>
- <Property name="text" type="java.lang.String" value="この文字に置換"/>
- </Properties>
- </Component>
- <Component class="javax.swing.JTextField" name="replaceFromField">
- </Component>
- <Component class="javax.swing.JTextField" name="replaceToField">
- </Component>
</SubComponents>
</Container>
</SubComponents>
String filePattern = config.getFileNamePattern();
namePatternField.setText(filePattern);
namePatternArea.setCaretPosition(0);
- String replaceFrom = config.getFileNameReplaceFrom();
- replaceFromField.setText(replaceFrom);
- String replaceTo = config.getFileNameReplaceTo();
- replaceToField.setText(replaceTo);
// 動作
waitSpinner.setValue(config.getWaitTime());
namePatternScroll = new javax.swing.JScrollPane();
namePatternArea = new javax.swing.JTextArea();
namePatternLabel = new javax.swing.JLabel();
- replaceFromLabel = new javax.swing.JLabel();
- replaceToLabel = new javax.swing.JLabel();
- replaceFromField = new javax.swing.JTextField();
- replaceToField = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("NicoBrowser - コンフィグ設定");
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
- .add(org.jdesktop.layout.GroupLayout.LEADING, mylistFileLabel, 0, 0, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, mylistFileLabel, 0, 1, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, configFileLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, feedFileLabel))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
namePatternLabel.setText("命名規則");
- replaceFromLabel.setText("置換対象文字");
-
- replaceToLabel.setText("この文字に置換");
-
org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel6Layout.createSequentialGroup()
.add(namePatternLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(namePatternField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE))
- .add(jPanel6Layout.createSequentialGroup()
- .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(replaceToLabel)
- .add(replaceFromLabel))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(replaceFromField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
- .add(replaceToField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE))))
+ .add(namePatternField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel6Layout.setVerticalGroup(
.add(namePatternLabel))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(namePatternScroll, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(replaceFromLabel)
- .add(replaceFromField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(replaceToLabel)
- .add(replaceToField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
p.setProperty(Config.P_PATH_DB, dbPathField.getText());
p.setProperty(Config.P_PATH_SAVEFILE, flvPathField.getText());
p.setProperty(Config.P_SAVEFILE_PATTERN, namePatternField.getText());
- p.setProperty(Config.P_SAVEFILE_REPLACE_FROM, replaceFromField.getText());
- p.setProperty(Config.P_SAVEFILE_REPLACE_TO, replaceToField.getText());
p.setProperty(Config.P_DOWNLOAD_WAIT, waitSpinner.getValue().toString());
p.setProperty(Config.P_DOWNLOAD_RETRY, retrySpinner.getValue().toString());
private javax.swing.JScrollPane namePatternScroll;
private javax.swing.JPasswordField passField;
private javax.swing.JLabel passLabel;
- private javax.swing.JTextField replaceFromField;
- private javax.swing.JLabel replaceFromLabel;
- private javax.swing.JTextField replaceToField;
- private javax.swing.JLabel replaceToLabel;
private javax.swing.JSpinner retrySpinner;
private javax.swing.JButton savaButton;
private javax.swing.JSpinner waitSpinner;
}
prevDate = Calendar.getInstance().getTime();
File saveDir = new File(config.getSrcSaveDir());
- NamePattern np = new NamePattern(config.getFileNamePattern(), config.getFileNameReplaceFrom(), config.
- getFileNameReplaceTo(), c.getTitle());
+ NamePattern np = new NamePattern(config.getFileNamePattern(), c.getTitle());
log.info("ファイルを取得します: " + c.getNicoId() + " " + c.getTitle());
final boolean authed = instance.challengeAuth();
if (!authed) {
String res;
System.out.println("createFileName");
- NamePattern np = new NamePattern("{title}{title}", "*\\/\"", "_", title);
+ NamePattern np = new NamePattern("{title}{title}", title);
res = np.createFileName("sm9", true);
- assertEquals("_タ_イ_ト_ル_タ_イ_ト_ル", res);
+ assertEquals("*タ¥イ/ト”ル*タ¥イ/ト”ル", res);
- NamePattern np2 = new NamePattern("[{id}]{title}", "9タ", "-", title);
+ NamePattern np2 = new NamePattern("[{id}]{title}", title);
res = np2.createFileName(id, false);
- assertEquals("[sm----]*-¥イ/ト”ル", res);
+ assertEquals("[sm9999]*タ¥イ/ト”ル", res);
- NamePattern np3 = new NamePattern("{id}{low}_{title}", "", "", title);
+ NamePattern np3 = new NamePattern("{id}{low}_{title}", title);
res = np3.createFileName(id, false);
assertEquals("sm9999low_*タ¥イ/ト”ル", res);
- NamePattern np4 = new NamePattern("{id}{low}_{title}", "/*-", "*", title);
+ NamePattern np4 = new NamePattern("{id}{low}_{title}", title);
res = np4.createFileName(id, true);
- assertEquals("sm9999_ï¼\8aã\82¿ï¿¥ã\82¤ï¼\8aト”ル", res);
+ assertEquals("sm9999_ï¼\8aã\82¿ï¿¥ã\82¤ï¼\8fト”ル", res);
}
}