meta.setSubject("MLP");
meta.setType(getType().toString());
meta.setImageDocument(false);
- meta.setCover(getImage(this, null,
- getKeyJson(json, 0, "type", "story", "cover_image", "full")));
+
+ String coverImageLink =
+ getKeyJson(json, 0, "type", "story", "cover_image", "full");
+ if (!coverImageLink.trim().isEmpty()) {
+ meta.setCover(getImage(this, null, coverImageLink.trim()));
+ }
return meta;
}
while (pos >= 0) {
pos = indexOfJsonAfter(json, pos, "type", "story_tag");
if (pos >= 0) {
- tags.add(getKeyJson(json, pos, "name"));
+ tags.add(getKeyJson(json, pos, "name").trim());
}
}
final String title = getKeyJson(json, pos, "title");
String notes = getKeyJson(json, pos, "authors_note_html");
String content = getKeyJson(json, pos, "content_html");
-
+
+ if (!notes.trim().isEmpty()) {
+ notes = "<br/>* * *<br/>" + notes;
+ }
+
chapterNames.put(number, title);
chapterContents
- .put(number, content + "<br/>* * *<br/>" + notes);
+ .put(number, content + notes);
urls.add(new Entry<String, URL>() {
@Override
}
// afters: [name, value] pairs (or "" for any of them), can end without
- // value
+ // value but will then be empty, not NULL
static private String getKeyJson(String json, int startAt,
String... afterKeys) {
int pos = indexOfJsonAfter(json, startAt, afterKeys);
if (pos < 0) {
- return null;
+ return "";
}
- String result = null;
+ String result = "";
String wip = json.substring(pos);
pos = nextUnescapedQuote(wip, 0);
result = wip.substring(0, pos);
}
}
-
+
+ result = result.replace("\\t", "\t")
+ .replace("\\\"", "\"");
+
return result;
}