Add more warnings source to 1.6) and fix warnings
[nikiroo-utils.git] / src / be / nikiroo / fanfix / supported / InfoReader.java
index ede84e39a5c4f945a49f9fbc1c512ab7b84c4ba1..466a88539bd375e236376b24f3d0fa5772b7489d 100644 (file)
@@ -9,6 +9,8 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
+import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.bundles.Config;
 import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.utils.MarkableFileInputStream;
 
@@ -29,11 +31,11 @@ public class InfoReader {
                                in.close();
                                in = null;
                        }
-               } else {
-                       throw new FileNotFoundException(
-                                       "File given as argument does not exists: "
-                                                       + infoFile.getAbsolutePath());
                }
+
+               throw new FileNotFoundException(
+                               "File given as argument does not exists: "
+                                               + infoFile.getAbsolutePath());
        }
 
        private static MetaData createMeta(URL sourceInfoFile, InputStream in,
@@ -56,6 +58,18 @@ public class InfoReader {
                if (withCover) {
                        meta.setCover(BasicSupport.getImage(null, sourceInfoFile,
                                        getInfoTag(in, "COVER")));
+                       // 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);
+                                       meta.setCover(BasicSupport.getImage(null, sourceInfoFile,
+                                                       info + ext));
+                               }
+                       }
                }
                try {
                        meta.setWords(Long.parseLong(getInfoTag(in, "WORDCOUNT")));