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.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.data.MetaData;
+import be.nikiroo.utils.Image;
import be.nikiroo.utils.Progress;
import be.nikiroo.utils.StringUtils;
*
* @author niki
*/
-class Fimfiction extends BasicSupport {
+class Fimfiction extends BasicSupport_Deprecated {
@Override
protected boolean isHtml() {
return true;
}
- @Override
- public String getSourceName() {
- return "FimFiction.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");
+ meta.setLang("en");
meta.setSubject("MLP");
meta.setType(getType().toString());
meta.setImageDocument(false);
break; // end of *this story* tags
}
- String tab[] = line.split("<li>");
- for (String subline : tab) {
- subline = StringUtils.unhtml(subline).trim();
- if (!subline.isEmpty() && !tags.contains(subline)) {
- tags.add(subline);
+ String keyword = "title=\"";
+ Scanner tagScanner = new Scanner(line);
+ tagScanner.useDelimiter(keyword);
+ if (tagScanner.hasNext()) {
+ tagScanner.next();// Ignore first one
+ }
+ while (tagScanner.hasNext()) {
+ String tag = tagScanner.next();
+ if (tag.contains("\"")) {
+ tag = tag.split("\"")[0];
+ tag = StringUtils.unhtml(tag).trim();
+ if (!tag.isEmpty() && !tags.contains(tag)) {
+ tags.add(tag);
+ }
}
}
+ tagScanner.close();
}
}
return getLine(in, "class=\"description-text bbcode\"", 1);
}
- private BufferedImage getCover(InputStream in) {
+ private Image getCover(InputStream in) {
// Note: the 'og:image' is the SMALL cover, not the full version
String cover = getLine(in, "class=\"story_container__story_image\"", 1);
if (cover != null) {
break;
}
- if (line.startsWith("<a href=")) {
+ if (line.startsWith("<a href=")
+ || line.contains("class=\"chapter-title\"")) {
// Chapter name
String name = line;
int pos = name.indexOf('>');
}
try {
- final String key = name;
- final URL value = new URL("http://www.fimfiction.net"
- + line);
- urls.add(new Entry<String, URL>() {
- public URL setValue(URL value) {
- return null;
- }
-
- public String getKey() {
- return key;
- }
-
- public URL getValue() {
- return value;
- }
- });
+ urls.add(new AbstractMap.SimpleEntry<String, URL>(name,
+ new URL("http://www.fimfiction.net" + line)));
} catch (MalformedURLException e) {
- Instance.syserr(e);
+ Instance.getInstance().getTraceHandler().error(e);
}
}
}