package be.nikiroo.fanfix.supported;
-import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
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;
import java.util.Scanner;
import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.bundles.Config;
import be.nikiroo.fanfix.data.MetaData;
+import be.nikiroo.utils.Image;
+import be.nikiroo.utils.Progress;
import be.nikiroo.utils.StringUtils;
/**
*
* @author niki
*/
-class Fanfiction extends BasicSupport {
+class Fanfiction extends BasicSupport_Deprecated {
@Override
protected boolean isHtml() {
return true;
meta.setPublisher(getSourceName());
meta.setUuid(source.toString());
meta.setLuid("");
- meta.setLang("EN");
+ meta.setLang("en"); // TODO!
meta.setSubject(getSubject(reset(in)));
meta.setType(getType().toString());
meta.setImageDocument(false);
return null;
}
- private List<String> getTags(InputStream in) throws IOException {
+ private List<String> getTags(InputStream in) {
List<String> tags = new ArrayList<String>();
String key = "title=\"Send Private Message\"";
}
}
- return fixAuthor(author);
+ return BasicSupportHelper.fixAuthor(author);
}
private String getDate(InputStream in) {
return sdf
.format(new Date(1000 * Long.parseLong(line)));
} catch (NumberFormatException e) {
- Instance.syserr(new IOException(
- "Cannot convert publication date: " + line, e));
+ Instance.getTraceHandler().error(
+ new IOException(
+ "Cannot convert publication date: "
+ + line, e));
}
}
}
return getLine(in, "title=\"Send Private Message\"", 1);
}
- private BufferedImage getCover(URL url, InputStream in) {
+ private Image getCover(URL url, InputStream in) {
String key = "class='cimage";
String line = getLine(in, key, 0);
if (line != null) {
}
@Override
- protected List<Entry<String, URL>> getChapters(URL source, InputStream in) {
+ protected List<Entry<String, URL>> getChapters(URL source, InputStream in,
+ Progress pg) {
List<Entry<String, URL>> urls = new ArrayList<Entry<String, URL>>();
String base = source.toString();
}
try {
- final String chapName = name.trim();
- final URL chapURL = new URL(base + i + suffix);
- urls.add(new Entry<String, URL>() {
- public URL setValue(URL value) {
- return null;
- }
-
- public URL getValue() {
- return chapURL;
- }
-
- public String getKey() {
- return chapName;
- }
- });
+ urls.add(new AbstractMap.SimpleEntry<String, URL>(
+ name.trim(), new URL(base + i + suffix)));
} catch (MalformedURLException e) {
- Instance.syserr(new IOException(
- "Cannot parse chapter " + i + " url: "
- + (base + i + suffix), e));
+ Instance.getTraceHandler()
+ .error(new IOException(
+ "Cannot parse chapter " + i
+ + " url: "
+ + (base + i + suffix), e));
}
}
}
final String chapName = getTitle(reset(in));
final URL chapURL = source;
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;
}
}
@Override
- protected String getChapterContent(URL source, InputStream in, int number) {
+ protected String getChapterContent(URL source, InputStream in, int number,
+ Progress pg) {
StringBuilder builder = new StringBuilder();
String startAt = "class='storytext ";
String endAt1 = "function review_init";
if (builder.length() == 0) {
int pos = line.indexOf("<hr");
if (pos >= 0) {
- line = line.substring(pos);
+ boolean chaptered = false;
+ for (String lang : Instance.getConfig()
+ .getString(Config.CHAPTER).split(",")) {
+ String chapterWord = Instance.getConfig()
+ .getStringX(Config.CHAPTER, lang);
+ int posChap = line.indexOf(chapterWord + " ");
+ if (posChap < pos) {
+ chaptered = true;
+ break;
+ }
+ }
+
+ if (chaptered) {
+ line = line.substring(pos);
+ }
}
}
builder.append(line);
+ builder.append(' ');
}
}