package be.nikiroo.fanfix.supported;
+import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Scanner;
import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.utils.StringUtils;
/**
}
@Override
- protected String getSubject(URL source, InputStream in) {
+ protected MetaData getMeta(URL source, InputStream in) throws IOException {
+ MetaData meta = new MetaData();
+
+ meta.setTitle(getTitle(reset(in)));
+ meta.setAuthor(getAuthor(reset(in)));
+ meta.setDate(getDate(reset(in)));
+ meta.setTags(getTags(reset(in)));
+ meta.setSource(getSourceName());
+ meta.setPublisher(getSourceName());
+ meta.setUuid(source.toString());
+ meta.setLuid("");
+ meta.setLang("EN");
+ meta.setSubject(getSubject(reset(in)));
+ meta.setType(getType().toString());
+ meta.setImageDocument(false);
+ meta.setCover(getCover(source, reset(in)));
+
+ return meta;
+ }
+
+ private String getSubject(InputStream in) {
String line = getLine(in, "id=pre_story_links", 0);
if (line != null) {
int pos = line.lastIndexOf('"');
line = line.substring(pos + 1);
pos = line.indexOf('<');
if (pos >= 0) {
- return line.substring(0, pos);
+ return StringUtils.unhtml(line.substring(0, pos)).trim();
}
}
}
return null;
}
- @Override
- protected List<String> getTags(URL source, InputStream in)
- throws IOException {
- List<String> tags = super.getTags(source, in);
+ private List<String> getTags(InputStream in) throws IOException {
+ List<String> tags = new ArrayList<String>();
String key = "title=\"Send Private Message\"";
String line = getLine(in, key, 2);
}
for (String tag : line.split("-")) {
- tags.add(tag.trim());
+ tags.add(StringUtils.unhtml(tag).trim());
}
}
}
return tags;
}
- @Override
- protected String getTitle(URL source, InputStream in) {
+ private String getTitle(InputStream in) {
int i = 0;
@SuppressWarnings("resource")
Scanner scan = new Scanner(in, "UTF-8");
line = line.substring("Follow/Fav".length()).trim();
}
- return line;
+ return StringUtils.unhtml(line).trim();
}
}
}
return null;
}
- @Override
- protected String getAuthor(URL source, InputStream in) {
+ private String getAuthor(InputStream in) {
int i = 0;
@SuppressWarnings("resource")
Scanner scan = new Scanner(in, "UTF-8");
return null;
}
- @Override
- protected String getDate(URL source, InputStream in) {
+ private String getDate(InputStream in) {
String key = "Published: <span data-xutime='";
String line = getLine(in, key, 0);
if (line != null) {
return getLine(in, "title=\"Send Private Message\"", 1);
}
- @Override
- protected URL getCover(URL url, InputStream in) {
+ private BufferedImage getCover(URL url, InputStream in) {
String key = "class='cimage";
String line = getLine(in, key, 0);
if (line != null) {
+ "/" + url.getPath() + "/" + line;
}
- try {
- return new URL(line);
- } catch (MalformedURLException e) {
- Instance.syserr(e);
- }
+ return getImage(null, line);
}
}
}