+ @Override
+ public synchronized Story getStory(final String luid, Progress pg)
+ throws IOException {
+
+ // TODO: pg
+
+ Story story;
+ InputStream in = download(WebLibraryUrls.getStoryUrlJson(luid));
+ try {
+ JSONObject json = new JSONObject(IOUtils.readSmallStream(in));
+ story = JsonIO.toStory(json);
+ } finally {
+ in.close();
+ }
+
+ 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 = download(
+ WebLibraryUrls.getStoryUrl(luid, chapNum, number));
+ try {
+ para.setContentImage(new Image(subin));
+ } finally {
+ subin.close();
+ }
+ }
+
+ number++;
+ }
+
+ chapNum++;
+ }
+
+ return story;
+ }
+