if (tmpInfo.exists()) {
meta = InfoReader.readMeta(tmpInfo, true);
- if (cover != null) {
- meta.setCover(cover);
- }
tmpInfo.delete();
} else {
if (title == null || title.isEmpty()) {
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();
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
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 {
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);