X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=supported%2FBasicSupport_Deprecated.java;h=9aac6d5c61b713a4641fc251796b981e48d3a2ec;hp=98b74db5d0567f9d415b6da23a3d849a79faa8ed;hb=258e065f81071a861711ef935dca3ec5563f4360;hpb=920af1c747538e949df24d29cf778d597be9a482 diff --git a/supported/BasicSupport_Deprecated.java b/supported/BasicSupport_Deprecated.java index 98b74db..9aac6d5 100644 --- a/supported/BasicSupport_Deprecated.java +++ b/supported/BasicSupport_Deprecated.java @@ -203,10 +203,16 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { pg.setProgress(30); Story story = new Story(); + MetaData meta = getMeta(url, getInput()); + meta.setType(getType().toString()); + meta.setSource(getType().getSourceName()); + meta.setPublisher(getType().getSourceName()); + if (meta.getCreationDate() == null - || meta.getCreationDate().isEmpty()) { - meta.setCreationDate(StringUtils.fromTime(new Date().getTime())); + || meta.getCreationDate().trim().isEmpty()) { + meta.setCreationDate(bsHelper.formatDate( + StringUtils.fromTime(new Date().getTime()))); } story.setMeta(meta); pg.put("meta", meta); @@ -269,8 +275,6 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { pgMeta.setProgress(pgMeta.getMax()); // 10% } - pg.setName("Retrieving " + story.getMeta().getTitle()); - setCurrentReferer(url); Progress pgGetChapters = new Progress(); @@ -318,7 +322,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(); @@ -327,14 +330,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(); @@ -374,7 +394,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 @@ -430,7 +450,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 @@ -448,7 +468,6 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { } List paras = new ArrayList(); - if (content != null && !content.trim().isEmpty()) { if (isHtml()) { String[] tab = content.split("(

|

|
|
)"); @@ -513,7 +532,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; @@ -637,7 +656,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) { @@ -863,7 +888,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();