import java.util.Map.Entry;
import java.util.Scanner;
-import javax.imageio.ImageIO;
-
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.data.MetaData;
+import be.nikiroo.utils.ImageUtils;
+import be.nikiroo.utils.Progress;
import be.nikiroo.utils.StringUtils;
class MangaFox extends BasicSupport {
if (authors.isEmpty()) {
return null;
- } else {
- StringBuilder builder = new StringBuilder();
- for (String author : authors) {
- if (builder.length() > 0) {
- builder.append(", ");
- }
+ }
- builder.append(author);
+ StringBuilder builder = new StringBuilder();
+ for (String author : authors) {
+ if (builder.length() > 0) {
+ builder.append(", ");
}
- return builder.toString();
+ builder.append(author);
}
+
+ return builder.toString();
}
private String getDate(InputStream in) {
try {
coverIn = openEx(cover);
try {
- return ImageIO.read(coverIn);
+ return ImageUtils.fromStream(coverIn);
} finally {
coverIn.close();
}
}
@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 volumeAt = "<h3 class=\"volume\">";
}
}
- // to help with the retry and the originalUrl
- refresh(url);
-
try {
final String key = name;
final URL value = new URL(url);
urls.add(new Entry<String, URL>() {
+ @Override
public URL setValue(URL value) {
return null;
}
+ @Override
public String getKey() {
return key;
}
+ @Override
public URL getValue() {
return value;
}
}
}
+ if (pg == null) {
+ pg = new Progress(0, urls.size());
+ } else {
+ pg.setMinMax(0, urls.size());
+ }
+
+ int i = 1;
+ for (Entry<String, URL> entry : urls) {
+ // to help with the retry and the originalUrl
+ refresh(entry.getValue().toString());
+ pg.setProgress(i++);
+ }
+
// the chapters are in reversed order
Collections.reverse(urls);
}
@Override
- protected String getChapterContent(URL source, InputStream in, int number) {
+ protected String getChapterContent(URL source, InputStream in, int number,
+ Progress pg) {
+ if (pg == null) {
+ pg = new Progress();
+ } else {
+ // Since we have no idea how many images we have, we cycle from 0
+ // to max, then again, then again...
+ pg.setMinMax(0, 20);
+ }
+
StringBuilder builder = new StringBuilder();
String base = getCurrentReferer().toString();
int pos = base.lastIndexOf('/');
base = base.substring(0, pos + 1); // including the '/' at the end
+ int i = 1;
boolean close = false;
while (in != null) {
String linkNextLine = getLine(in, "return enlarge()", 0);
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
refresh(linkImage);
+ pg.setProgress((i++) % pg.getMax());
if (close) {
try {
url = new URL(base + linkNext);
in = openEx(base + linkNext);
setCurrentReferer(url);
+ pg.setProgress((i++) % pg.getMax());
} catch (IOException e) {
Instance.syserr(new IOException(
"Cannot get the next manga page which is: "