+ Map<String, String> post = new HashMap<String, String>();
+ post.put("luid", luid);
+ post(WebLibraryUrls.getCoverUrlAuthor(author), post).close();
+ }
+
+ @Override
+ public synchronized Story getStory(final String luid, Progress pg)
+ throws IOException {
+ if (pg == null) {
+ pg = new Progress();
+ }
+
+ Story story;
+ InputStream in = post(WebLibraryUrls.getStoryUrlJson(luid));
+ try {
+ JSONObject json = new JSONObject(IOUtils.readSmallStream(in));
+ story = JsonIO.toStory(json);
+ } finally {
+ in.close();
+ }
+
+ int max = 0;
+ for (Chapter chap : story) {
+ max += chap.getParagraphs().size();
+ }
+ pg.setMinMax(0, max);
+
+ story.getMeta().setCover(getCover(luid));
+ int chapNum = 1;
+ for (Chapter chap : story) {
+ int number = 1;
+ for (Paragraph para : chap) {
+ if (para.getType() == ParagraphType.IMAGE) {
+ InputStream subin = post(
+ WebLibraryUrls.getStoryUrl(luid, chapNum, number));
+ try {
+ Image img = new Image(subin);
+ if (img.getSize() > 0) {
+ para.setContentImage(img);
+ }
+ } finally {
+ subin.close();
+ }
+ }
+
+ pg.add(1);
+ number++;
+ }
+
+ chapNum++;
+ }
+
+ pg.done();
+ return story;