X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FFimfictionApi.java;h=52678e402a2e1c98b65560b12a0a8df825424252;hp=6ef8a2cc70d8bb65e7c32b4b94fce81d96f07bea;hb=ce297a794b1b7d3aa4e9234a6511dd9fe7216656;hpb=23b6932d10d2cc2d58456b0489219109f017b762 diff --git a/src/be/nikiroo/fanfix/supported/FimfictionApi.java b/src/be/nikiroo/fanfix/supported/FimfictionApi.java index 6ef8a2c..52678e4 100644 --- a/src/be/nikiroo/fanfix/supported/FimfictionApi.java +++ b/src/be/nikiroo/fanfix/supported/FimfictionApi.java @@ -3,11 +3,13 @@ package be.nikiroo.fanfix.supported; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.TreeMap; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.bundles.Config; @@ -132,9 +134,9 @@ class FimfictionApi extends BasicSupport_Deprecated { meta.setSubject("MLP"); meta.setType(getType().toString()); meta.setImageDocument(false); - - String coverImageLink = - 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())); } @@ -166,10 +168,8 @@ class FimfictionApi extends BasicSupport_Deprecated { @Override protected List> getChapters(URL source, InputStream in, Progress pg) { - List> urls = new ArrayList>(); - - chapterNames = new HashMap(); - chapterContents = new HashMap(); + chapterNames = new TreeMap(); + chapterContents = new TreeMap(); int pos = 0; while (pos >= 0) { @@ -182,34 +182,21 @@ class FimfictionApi extends BasicSupport_Deprecated { 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); - - urls.add(new Entry() { - @Override - public URL setValue(URL value) { - return null; - } - - @Override - public String getKey() { - return title; - } - - @Override - public URL getValue() { - return null; - } - }); + chapterContents.put(number, content + notes); } } + List> urls = new ArrayList>(); + for (String title : chapterNames.values()) { + urls.add(new AbstractMap.SimpleEntry(title, null)); + } + return urls; } @@ -311,10 +298,9 @@ class FimfictionApi extends BasicSupport_Deprecated { result = wip.substring(0, pos); } } - - result = result.replace("\\t", "\t") - .replace("\\\"", "\""); - + + result = result.replace("\\t", "\t").replace("\\\"", "\""); + return result; }