X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FWebLibrary.java;h=7f775830edf8c7641eeb3303abdddf3fcdb48fbd;hp=369eb23491cd6410cf45027f95a8a0612ee324d5;hb=c5103223c48d55a178f30e972313b009d8f79056;hpb=28b6ea54709eeb435a00edea59db10b02acd431a diff --git a/src/be/nikiroo/fanfix/library/WebLibrary.java b/src/be/nikiroo/fanfix/library/WebLibrary.java index 369eb23..7f77583 100644 --- a/src/be/nikiroo/fanfix/library/WebLibrary.java +++ b/src/be/nikiroo/fanfix/library/WebLibrary.java @@ -13,8 +13,11 @@ import org.json.JSONArray; import org.json.JSONObject; import be.nikiroo.fanfix.Instance; +import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.JsonIO; import be.nikiroo.fanfix.data.MetaData; +import be.nikiroo.fanfix.data.Paragraph; +import be.nikiroo.fanfix.data.Paragraph.ParagraphType; import be.nikiroo.fanfix.data.Story; import be.nikiroo.utils.IOUtils; import be.nikiroo.utils.Image; @@ -135,6 +138,18 @@ public class WebLibrary extends BasicLibrary { return null; } + @Override + public Image getCustomSourceCover(final String source) throws IOException { + // TODO maybe global system in BasicLib ? + return null; + } + + @Override + public Image getCustomAuthorCover(final String author) throws IOException { + // TODO maybe global system in BasicLib ? + return null; + } + @Override public void setSourceCover(String source, String luid) throws IOException { // TODO Auto-generated method stub @@ -147,6 +162,45 @@ public class WebLibrary extends BasicLibrary { throw new IOException("Not implemented yet"); } + @Override + public synchronized Story getStory(final String luid, Progress pg) + throws IOException { + + // TODO: pg + + Story story; + InputStream in = download("/story/" + luid + "/json"); + 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( + "/story/" + luid + "/" + chapNum + "/" + number); + try { + para.setContentImage(new Image(subin)); + } finally { + subin.close(); + } + } + + number++; + } + + chapNum++; + } + + return story; + } + @Override protected List getMetas(Progress pg) throws IOException { List metas = new ArrayList();