", 1);
+ String cover = getLine(in, "class=\"story_container__story_image\"", 1);
if (cover != null) {
int pos = cover.indexOf('"');
if (pos >= 0) {
@@ -156,66 +183,55 @@ class Fimfiction extends BasicSupport {
}
}
- if (cover != null) {
- try {
- return new URL(cover);
- } catch (MalformedURLException e) {
- Instance.syserr(e);
- }
- }
-
- return null;
+ return getImage(this, null, cover);
}
@Override
- protected List
> getChapters(URL source, InputStream in) {
+ protected List> getChapters(URL source, InputStream in,
+ Progress pg) {
List> urls = new ArrayList>();
@SuppressWarnings("resource")
Scanner scan = new Scanner(in, "UTF-8");
scan.useDelimiter("\\n");
+ boolean started = false;
while (scan.hasNext()) {
- String line = scan.next();
- if (line.contains("class=\"chapter_link\"")
- || line.contains("class='chapter_link'")) {
- // Chapter name
- String name = line;
- int pos = name.indexOf('>');
- if (pos >= 0) {
- name = name.substring(pos + 1);
- pos = name.indexOf('<');
- if (pos >= 0) {
- name = name.substring(0, pos);
- }
- }
- // Chapter content
- pos = line.indexOf('/');
- if (pos >= 0) {
- line = line.substring(pos); // we take the /, not +1
- pos = line.indexOf('"');
- if (pos >= 0) {
- line = line.substring(0, pos);
- }
+ String line = scan.next().trim();
+
+ if (!started) {
+ started = line.equals("");
+ } else {
+ if (line.equals("")) {
+ break;
}
- try {
- final String key = name;
- final URL value = new URL("http://www.fimfiction.net"
- + line);
- urls.add(new Entry() {
- public URL setValue(URL value) {
- return null;
+ if (line.startsWith("');
+ if (pos >= 0) {
+ name = name.substring(pos + 1);
+ pos = name.indexOf('<');
+ if (pos >= 0) {
+ name = name.substring(0, pos);
}
-
- public String getKey() {
- return key;
+ }
+ // Chapter content
+ pos = line.indexOf('/');
+ if (pos >= 0) {
+ line = line.substring(pos); // we take the /, not +1
+ pos = line.indexOf('"');
+ if (pos >= 0) {
+ line = line.substring(0, pos);
}
+ }
- public URL getValue() {
- return value;
- }
- });
- } catch (MalformedURLException e) {
- Instance.syserr(e);
+ try {
+ urls.add(new AbstractMap.SimpleEntry(name,
+ new URL("http://www.fimfiction.net" + line)));
+ } catch (MalformedURLException e) {
+ Instance.getInstance().getTraceHandler().error(e);
+ }
}
}
}
@@ -224,8 +240,9 @@ class Fimfiction extends BasicSupport {
}
@Override
- protected String getChapterContent(URL source, InputStream in, int number) {
- return getLine(in, "", 1);
+ protected String getChapterContent(URL source, InputStream in, int number,
+ Progress pg) {
+ return getLine(in, "
", 1);
}
@Override