try +1
authorNiki Roo <niki@nikiroo.be>
Fri, 10 Aug 2018 17:18:55 +0000 (19:18 +0200)
committerNiki Roo <niki@nikiroo.be>
Fri, 10 Aug 2018 17:18:55 +0000 (19:18 +0200)
src/be/nikiroo/fanfix/library/BasicLibrary.java
src/be/nikiroo/fanfix/supported/BasicSupport.java
src/be/nikiroo/fanfix/supported/E621.java
src/be/nikiroo/fanfix/supported/Epub.java
src/be/nikiroo/fanfix/supported/InfoReader.java

index a9b6ef3b1e19e0c259a49d136311605e19c1fa85..58bd873a25175f38a0385bc525db340f226d2db8 100644 (file)
@@ -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:
index ed92b2f37821342771f27eb22841ca53a6aa994b..8154a15e600564e3bfb1da2d9211030512efc72b 100644 (file)
@@ -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()));
                }
index c57f8fd2cfbe0c565f15904cc5873a085acbb8b3..407ec70ee996123e2b759e2169802fb86cfec63a 100644 (file)
@@ -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;
        }
 
index 5a1fe43ce1e87929ee70e11e43c4d461f4ba3fc1..356e3a88fcbdb9d43905a5c6717ed10c62309cb1 100644 (file)
@@ -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();
index 8e1c385cfa8d115fd9fd6035be77eac10c580611..80f873989ad03b95db685ffa94603fa7f4e4f30f 100644 (file)
@@ -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);