import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
+import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
return true;
}
- @Override
- public String getSourceName() {
- return "Fanfiction.net";
- }
-
@Override
protected MetaData getMeta(URL source, InputStream in) throws IOException {
MetaData meta = new MetaData();
meta.setAuthor(getAuthor(reset(in)));
meta.setDate(getDate(reset(in)));
meta.setTags(getTags(reset(in)));
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(source.toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(getType().getSourceName());
meta.setUuid(source.toString());
meta.setLuid("");
- meta.setLang("en"); //TODO!
+ meta.setLang("en"); // TODO find language of book
meta.setSubject(getSubject(reset(in)));
meta.setType(getType().toString());
meta.setImageDocument(false);
}
}
- return null;
+ return "";
}
private String getAuthor(InputStream in) {
}
}
- return BasicSupportHelper.fixAuthor(author);
+ return bsHelper.fixAuthor(author);
}
private String getDate(InputStream in) {
line = line.substring(0, pos).trim();
try {
SimpleDateFormat sdf = new SimpleDateFormat(
- "YYYY-MM-dd");
+ "yyyy-MM-dd");
return sdf
.format(new Date(1000 * Long.parseLong(line)));
} catch (NumberFormatException e) {
- Instance.getTraceHandler().error(
- new IOException(
- "Cannot convert publication date: "
- + line, e));
+ Instance.getInstance().getTraceHandler()
+ .error(new IOException("Cannot convert publication date: " + line, e));
}
}
}
}
try {
- final String chapName = name.trim();
- final URL chapURL = new URL(base + i + suffix);
- urls.add(new Entry<String, URL>() {
- @Override
- public URL setValue(URL value) {
- return null;
- }
-
- @Override
- public URL getValue() {
- return chapURL;
- }
-
- @Override
- public String getKey() {
- return chapName;
- }
- });
+ urls.add(new AbstractMap.SimpleEntry<String, URL>(
+ name.trim(), new URL(base + i + suffix)));
} catch (MalformedURLException e) {
- Instance.getTraceHandler()
- .error(new IOException(
- "Cannot parse chapter " + i
- + " url: "
- + (base + i + suffix), e));
+ Instance.getInstance().getTraceHandler().error(
+ new IOException("Cannot parse chapter " + i + " url: " + (base + i + suffix), e));
}
}
}
int pos = line.indexOf("<hr");
if (pos >= 0) {
boolean chaptered = false;
- for (String lang : Instance.getConfig()
- .getString(Config.CHAPTER).split(",")) {
- String chapterWord = Instance.getConfig()
- .getStringX(Config.CHAPTER, lang);
+ for (String lang : Instance.getInstance().getConfig().getList(Config.CONF_CHAPTER)) {
+ String chapterWord = Instance.getInstance().getConfig().getStringX(Config.CONF_CHAPTER,
+ lang);
int posChap = line.indexOf(chapterWord + " ");
if (posChap < pos) {
chaptered = true;