X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FBasicSupport_Deprecated.java;h=40ff3fc027c7e52beca3426017e1a6a58972fbbe;hp=bc3738a211bc22b92ac8811e85a549dd17777618;hb=0a264fbe3d5a43516006052574a5f322d9d38897;hpb=7949d4a5098d8554c333c9fbbda469488bc66f7e diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java b/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java index bc3738a..40ff3fc 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java @@ -317,7 +317,6 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { words += cc.getWords(); story.getChapters().add(cc); - story.getMeta().setWords(words); } finally { if (chapIn != null) { chapIn.close(); @@ -326,14 +325,31 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { i++; } + + story.getMeta().setWords(words); pgChaps.setName("Extracting chapters"); } else { pg.setProgress(80); } - return story; + // Check for "no chapters" stories + if (story.getChapters().isEmpty() + && story.getMeta().getResume() != null + && !story.getMeta().getResume().getParagraphs().isEmpty()) { + Chapter resume = story.getMeta().getResume(); + resume.setName(""); + resume.setNumber(1); + story.getChapters().add(resume); + story.getMeta().setWords(resume.getWords()); + + String descChapterName = Instance.getInstance().getTrans() + .getString(StringId.DESCRIPTION); + resume = new Chapter(0, descChapterName); + story.getMeta().setResume(resume); + } + return story; } finally { close(); @@ -373,7 +389,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { * @param pg * the optional progress reporter * - * @return the {@link Chapter} + * @return the {@link Chapter}, never NULL * * @throws IOException * in case of I/O error @@ -429,7 +445,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { * @param pg * the optional progress reporter * - * @return the {@link Paragraph}s + * @return the {@link Paragraph}s (can be empty, but never NULL) * * @throws IOException * in case of I/O error @@ -447,7 +463,6 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { } List paras = new ArrayList(); - if (content != null && !content.trim().isEmpty()) { if (isHtml()) { String[] tab = content.split("(

|

|
|
)"); @@ -512,7 +527,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { * @param line * the textual content of the paragraph * - * @return the {@link Paragraph} + * @return the {@link Paragraph}, never NULL */ private Paragraph makeParagraph(URL source, String line) { Image image = null; @@ -636,7 +651,13 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { InputStream in = null; try { in = Instance.getInstance().getCache().open(url, getSupport(url), true); - return new Image(in); + Image img = new Image(in); + if (img.getSize() == 0) { + img.close(); + throw new IOException( + "Empty image not accepted"); + } + return img; } catch (IOException e) { } finally { if (in != null) { @@ -862,7 +883,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { * @param line * the raw line * - * @return the processed {@link Paragraph} + * @return the processed {@link Paragraph}, never NULL */ protected Paragraph processPara(String line) { line = ifUnhtml(line).trim();