From: Niki Roo Date: Fri, 10 Aug 2018 17:18:55 +0000 (+0200) Subject: try +1 X-Git-Tag: fanfix-1.8.0~9 X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=commitdiff_plain;h=bb7021f2b3f1bf32d6ec7ad521ae7ae8d1810c57 try +1 --- diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index a9b6ef3..58bd873 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -353,7 +353,6 @@ abstract public class BasicLibrary { .getType()); URL url = file.toURI().toURL(); if (type != null) { -System.out.println("selected support: "+BasicSupport.getSupport(type, url)); story = BasicSupport.getSupport(type, url) // .process(pgProcess); // Because we do not want to clear the meta cache: diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport.java b/src/be/nikiroo/fanfix/supported/BasicSupport.java index ed92b2f..8154a15 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport.java @@ -294,7 +294,6 @@ public abstract class BasicSupport { Story story = new Story(); MetaData meta = getMeta(); -System.out.println("meta from support get: "+meta); if (meta.getCreationDate() == null || meta.getCreationDate().isEmpty()) { meta.setCreationDate(StringUtils.fromTime(new Date().getTime())); } diff --git a/src/be/nikiroo/fanfix/supported/E621.java b/src/be/nikiroo/fanfix/supported/E621.java index c57f8fd..407ec70 100644 --- a/src/be/nikiroo/fanfix/supported/E621.java +++ b/src/be/nikiroo/fanfix/supported/E621.java @@ -58,8 +58,6 @@ class E621 extends BasicSupport_Deprecated { meta.setCover(getCover(source, reset(in))); meta.setFakeCover(true); - System.out.println("Meta from e621: "+meta); - return meta; } diff --git a/src/be/nikiroo/fanfix/supported/Epub.java b/src/be/nikiroo/fanfix/supported/Epub.java index 5a1fe43..356e3a8 100644 --- a/src/be/nikiroo/fanfix/supported/Epub.java +++ b/src/be/nikiroo/fanfix/supported/Epub.java @@ -185,9 +185,6 @@ class Epub extends InfoText { if (tmpInfo.exists()) { meta = InfoReader.readMeta(tmpInfo, true); - if (cover != null) { - meta.setCover(cover); - } tmpInfo.delete(); } else { if (title == null || title.isEmpty()) { @@ -208,6 +205,17 @@ class Epub extends InfoText { meta.setAuthor(author); meta.setImageDocument(isImagesDocumentByDefault()); } + + if (meta.getCover() == null) { + if (cover != null) { + meta.setCover(cover); + } else { +System.out.println(">>> " + getSourceFileOriginal()); + meta.setCover(InfoReader + .getCoverByName(getSourceFileOriginal().toURI() + .toURL())); + } + } } finally { if (zipIn != null) { zipIn.close(); diff --git a/src/be/nikiroo/fanfix/supported/InfoReader.java b/src/be/nikiroo/fanfix/supported/InfoReader.java index 8e1c385..80f8739 100644 --- a/src/be/nikiroo/fanfix/supported/InfoReader.java +++ b/src/be/nikiroo/fanfix/supported/InfoReader.java @@ -13,6 +13,7 @@ import java.util.Scanner; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.data.MetaData; +import be.nikiroo.utils.Image; import be.nikiroo.utils.MarkableFileInputStream; // not complete: no "description" tag @@ -61,18 +62,9 @@ public class InfoReader { meta.setCover(BasicSupportHelper.getImage(null, sourceInfoFile, infoTag)); } - // Second chance: try to check for a cover next to the info file if (meta.getCover() == null) { - String info = sourceInfoFile.getFile().toString(); - if (info.endsWith(".info")) { - info = info.substring(0, info.length() - ".info".length()); - String ext = "." - + Instance.getConfig() - .getString(Config.IMAGE_FORMAT_COVER) - .toLowerCase(); - meta.setCover(BasicSupportHelper.getImage(null, - sourceInfoFile, info + ext)); - } + // Second chance: try to check for a cover next to the info file + meta.setCover(getCoverByName(sourceInfoFile)); } } try { @@ -90,6 +82,28 @@ public class InfoReader { return meta; } + /** + * Return the cover image if it is next to the source file. + * + * @param sourceInfoFile + * the source file + * + * @return the cover if present, NULL if not + */ + public static Image getCoverByName(URL sourceInfoFile) { + String info = sourceInfoFile.getFile().toString(); + if (info.endsWith(".info")) { + info = info.substring(0, info.length() - ".info".length()); + String ext = "." + + Instance.getConfig().getString(Config.IMAGE_FORMAT_COVER) + .toLowerCase(); + return BasicSupportHelper + .getImage(null, sourceInfoFile, info + ext); + } + + return null; + } + private static boolean getInfoTagBoolean(InputStream in, String key, boolean def) throws IOException { Boolean value = getInfoTagBoolean(in, key);