X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FFimfictionApi.java;h=3319bbeed3a93e0076747adf50607c0447a863a0;hp=9c3e71ddb00a1c4b7ad7f84ab7bc639401c539e1;hb=fce43164126e813a4cdb2571a4d8d83c885314e5;hpb=77e28d38d47dbfcf29030ee388854d59df3ef1d0 diff --git a/src/be/nikiroo/fanfix/supported/FimfictionApi.java b/src/be/nikiroo/fanfix/supported/FimfictionApi.java index 9c3e71d..3319bbe 100644 --- a/src/be/nikiroo/fanfix/supported/FimfictionApi.java +++ b/src/be/nikiroo/fanfix/supported/FimfictionApi.java @@ -132,8 +132,12 @@ class FimfictionApi extends BasicSupport { 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; } @@ -146,7 +150,7 @@ class FimfictionApi extends BasicSupport { 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()); } } @@ -178,10 +182,14 @@ class FimfictionApi extends BasicSupport { 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 = "
* * *
" + notes; + } + chapterNames.put(number, title); chapterContents - .put(number, content + "
* * *
" + notes); + .put(number, content + notes); urls.add(new Entry() { @Override @@ -283,15 +291,15 @@ class FimfictionApi extends BasicSupport { } // 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); @@ -302,7 +310,10 @@ class FimfictionApi extends BasicSupport { result = wip.substring(0, pos); } } - + + result = result.replace("\\t", "\t") + .replace("\\\"", "\""); + return result; }