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.IOUtils;
import be.nikiroo.utils.StringUtils;
class MangaFox extends BasicSupport {
}
@Override
- protected String getSubject(URL source, InputStream in) {
- return "manga";
+ 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.setUrl(source.toString());
+ meta.setPublisher(getSourceName());
+ meta.setUuid(source.toString());
+ meta.setLuid("");
+ meta.setLang("EN");
+ meta.setSubject("manga");
+ meta.setType(getType().toString());
+ meta.setImageDocument(true);
+ meta.setCover(getCover(reset(in)));
+
+ return meta;
}
- @Override
- public boolean isImageDocument(URL source, InputStream in)
- throws IOException {
- return true;
- }
-
- @Override
- protected List<String> getTags(URL source, InputStream in) {
+ private List<String> getTags(InputStream in) {
List<String> tags = new ArrayList<String>();
String line = getLine(in, "/genres/", 0);
return tags;
}
- @Override
- protected String getTitle(URL source, InputStream in) {
+ private String getTitle(InputStream in) {
String line = getLine(in, " property=\"og:title\"", 0);
if (line != null) {
int pos = -1;
return null;
}
- @Override
- protected String getAuthor(URL source, InputStream in) {
+ private String getAuthor(InputStream in) {
List<String> authors = new ArrayList<String>();
String line = getLine(in, "/author/", 0, false);
}
}
- @Override
- protected String getDate(URL source, InputStream in) {
+ private String getDate(InputStream in) {
String line = getLine(in, "/released/", 0);
if (line != null) {
line = StringUtils.unhtml(line);
return null;
}
- @Override
- protected URL getCover(URL url, InputStream in) {
+ private BufferedImage getCover(InputStream in) {
String line = getLine(in, " property=\"og:image\"", 0);
String cover = null;
if (line != null) {
}
if (cover != null) {
+ InputStream coverIn;
try {
- return new URL(cover);
- } catch (MalformedURLException e) {
- Instance.syserr(e);
+ coverIn = openEx(cover);
+ try {
+ return IOUtils.toImage(coverIn);
+ } finally {
+ coverIn.close();
+ }
+ } catch (IOException e) {
}
}
builder.append("[");
// to help with the retry and the originalUrl, part 1
builder.append(withoutQuery(linkImage));
- builder.append("]\n");
+ builder.append("]<br/>");
}
// to help with the retry and the originalUrl, part 2