X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FBasicSupport_Deprecated.java;h=47cb7a2c94ed2b965e865e398638d683a8967898;hb=97654d115d9f0286f9eea9fe50216cb3737e9ed6;hp=e22724a20aad5634fb38523dac7d9ddc231cf25f;hpb=6bfa27805ec903223e6e45c6f4d00e94629a064c;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java b/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java index e22724a..47cb7a2 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java @@ -40,17 +40,12 @@ import be.nikiroo.utils.StringUtils; @Deprecated public abstract class BasicSupport_Deprecated extends BasicSupport { private InputStream in; - private URL currentReferer; // with only one 'r', as in 'HTTP'... // quote chars - private char openQuote = Instance.getTrans().getCharacter( - StringId.OPEN_SINGLE_QUOTE); - private char closeQuote = Instance.getTrans().getCharacter( - StringId.CLOSE_SINGLE_QUOTE); - private char openDoubleQuote = Instance.getTrans().getCharacter( - StringId.OPEN_DOUBLE_QUOTE); - private char closeDoubleQuote = Instance.getTrans().getCharacter( - StringId.CLOSE_DOUBLE_QUOTE); + private char openQuote = Instance.getInstance().getTrans().getCharacter(StringId.OPEN_SINGLE_QUOTE); + private char closeQuote = Instance.getInstance().getTrans().getCharacter(StringId.CLOSE_SINGLE_QUOTE); + private char openDoubleQuote = Instance.getInstance().getTrans().getCharacter(StringId.OPEN_DOUBLE_QUOTE); + private char closeDoubleQuote = Instance.getInstance().getTrans().getCharacter(StringId.CLOSE_DOUBLE_QUOTE); // New methods not used in Deprecated mode @Override @@ -75,6 +70,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { throw new RuntimeException("should not be used by legacy code"); } + @Override public Story process(Progress pg) throws IOException { return process(getSource(), pg); } @@ -213,6 +209,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { meta.setCreationDate(StringUtils.fromTime(new Date().getTime())); } story.setMeta(meta); + pg.put("meta", meta); pg.setProgress(50); @@ -223,11 +220,8 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { pg.setProgress(60); if (getDesc) { - String descChapterName = Instance.getTrans().getString( - StringId.DESCRIPTION); - story.getMeta().setResume( - makeChapter(url, 0, descChapterName, - getDesc(url, getInput()), null)); + String descChapterName = Instance.getInstance().getTrans().getString(StringId.DESCRIPTION); + story.getMeta().setResume(makeChapter(url, 0, descChapterName, getDesc(url, getInput()), null)); } pg.setProgress(100); @@ -270,12 +264,11 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { Progress pgMeta = new Progress(); pg.addProgress(pgMeta, 10); Story story = processMeta(url, false, true, pgMeta); + pg.put("meta", story.getMeta()); if (!pgMeta.isDone()) { pgMeta.setProgress(pgMeta.getMax()); // 10% } - pg.setName("Retrieving " + story.getMeta().getTitle()); - setCurrentReferer(url); Progress pgGetChapters = new Progress(); @@ -299,8 +292,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { InputStream chapIn = null; if (chap.getValue() != null) { setCurrentReferer(chap.getValue()); - chapIn = Instance.getCache().open(chap.getValue(), - this, false); + chapIn = Instance.getInstance().getCache().open(chap.getValue(), this, false); } pgChaps.setProgress(i * 100); try { @@ -391,10 +383,8 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { // redundant "Chapter x: " in front of it, or "-" (as in // "Chapter 5: - Fun!" after the ": " was automatically added) String chapterName = processPara(name).getContent().trim(); - for (String lang : Instance.getConfig().getString(Config.CHAPTER) - .split(",")) { - String chapterWord = Instance.getConfig().getStringX( - Config.CHAPTER, lang); + for (String lang : Instance.getInstance().getConfig().getList(Config.CONF_CHAPTER)) { + String chapterWord = Instance.getInstance().getConfig().getStringX(Config.CONF_CHAPTER, lang); if (chapterName.startsWith(chapterWord)) { chapterName = chapterName.substring(chapterWord.length()) .trim(); @@ -592,10 +582,9 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { * @return the cover if any, or NULL */ static Image getDefaultCover(String subject) { - if (subject != null && !subject.isEmpty() - && Instance.getCoverDir() != null) { + if (subject != null && !subject.isEmpty() && Instance.getInstance().getCoverDir() != null) { try { - File fileCover = new File(Instance.getCoverDir(), subject); + File fileCover = new File(Instance.getInstance().getCoverDir(), subject); return getImage(null, fileCover.toURI().toURL(), subject); } catch (MalformedURLException e) { } @@ -645,7 +634,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { } InputStream in = null; try { - in = Instance.getCache().open(url, getSupport(url), true); + in = Instance.getInstance().getCache().open(url, getSupport(url), true); return new Image(in); } catch (IOException e) { } finally { @@ -681,7 +670,6 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { // try for files if (source != null) { try { - String relPath = null; String absPath = null; try { @@ -718,8 +706,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { // try for URLs try { for (String ext : getImageExt(true)) { - if (Instance.getCache() - .check(new URL(line + ext), true)) { + if (Instance.getInstance().getCache().check(new URL(line + ext), true)) { url = new URL(line + ext); break; } @@ -730,7 +717,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { for (String ext : getImageExt(true)) { try { url = new URL(line + ext); - Instance.getCache().refresh(url, support, true); + Instance.getInstance().getCache().refresh(url, support, true); break; } catch (IOException e) { // no image with this ext @@ -746,7 +733,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { // refresh the cached file if (url != null) { try { - Instance.getCache().refresh(url, support, true); + Instance.getInstance().getCache().refresh(url, support, true); } catch (IOException e) { // woops, broken image url = null; @@ -772,7 +759,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { * in case of I/O error */ protected InputStream openInput(URL source) throws IOException { - return Instance.getCache().open(source, this, false); + return Instance.getInstance().getCache().open(source, this, false); } /** @@ -1128,7 +1115,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { * the line to return based upon the target line position (-1 = * the line before, 0 = the target line...) * - * @return the line + * @return the line, or NULL if not found */ static protected String getLine(InputStream in, String needle, int relativeLine) { @@ -1152,7 +1139,7 @@ public abstract class BasicSupport_Deprecated extends BasicSupport { * takes the first result (as opposed to the last one, which will * also always spend the input) * - * @return the line + * @return the line, or NULL if not found */ static protected String getLine(InputStream in, String needle, int relativeLine, boolean first) {