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;
*
* @author niki
*/
-class FimfictionApi extends BasicSupport {
+class FimfictionApi extends BasicSupport_Deprecated {
private String oauth;
private String storyId;
private String json;
meta.setPublisher(getSourceName());
meta.setUuid(source.toString());
meta.setLuid("");
- meta.setLang("EN");
+ meta.setLang("en");
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()));
}
@Override
protected List<Entry<String, URL>> getChapters(URL source, InputStream in,
Progress pg) {
- List<Entry<String, URL>> urls = new ArrayList<Entry<String, URL>>();
-
- chapterNames = new HashMap<Integer, String>();
- chapterContents = new HashMap<Integer, String>();
+ chapterNames = new TreeMap<Integer, String>();
+ chapterContents = new TreeMap<Integer, String>();
int pos = 0;
while (pos >= 0) {
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 + notes);
-
- urls.add(new Entry<String, URL>() {
- @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<Entry<String, URL>> urls = new ArrayList<Entry<String, URL>>();
+ for (String title : chapterNames.values()) {
+ urls.add(new AbstractMap.SimpleEntry(title, null));
+ }
+
return urls;
}
result = wip.substring(0, pos);
}
}
-
- result = result.replace("\\t", "\t")
- .replace("\\\"", "\"");
-
+
+ result = result.replace("\\t", "\t").replace("\\\"", "\"");
+
return result;
}