X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FInfoReader.java;h=5203cc86107017c6fa3b3a236fe56f869def7c8c;hb=0ffa47548f474c1330d8d723300d9aa7a4894736;hp=ede84e39a5c4f945a49f9fbc1c512ab7b84c4ba1;hpb=57f02339393c9997391b76ffcb22ae72fd0a45cb;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/supported/InfoReader.java b/src/be/nikiroo/fanfix/supported/InfoReader.java index ede84e3..5203cc8 100644 --- a/src/be/nikiroo/fanfix/supported/InfoReader.java +++ b/src/be/nikiroo/fanfix/supported/InfoReader.java @@ -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, @@ -54,8 +56,24 @@ public class InfoReader { meta.setType(getInfoTag(in, "TYPE")); meta.setImageDocument(getInfoTagBoolean(in, "IMAGES_DOCUMENT", false)); if (withCover) { - meta.setCover(BasicSupport.getImage(null, sourceInfoFile, - getInfoTag(in, "COVER"))); + String infoTag = getInfoTag(in, "COVER"); + if (infoTag != null && !infoTag.trim().isEmpty()) { + 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)); + } + } } try { meta.setWords(Long.parseLong(getInfoTag(in, "WORDCOUNT"))); @@ -66,7 +84,7 @@ public class InfoReader { meta.setFakeCover(Boolean.parseBoolean(getInfoTag(in, "FAKE_COVER"))); if (withCover && meta.getCover() == null) { - meta.setCover(BasicSupport.getDefaultCover(meta.getSubject())); + meta.setCover(BasicSupportHelper.getDefaultCover(meta.getSubject())); } return meta; @@ -120,7 +138,7 @@ public class InfoReader { if (in != null) { in.reset(); - String value = BasicSupport.getLine(in, key, 0); + String value = BasicSupport_Deprecated.getLine(in, key, 0); if (value != null && !value.isEmpty()) { value = value.trim().substring(key.length() - 1).trim(); if (value.startsWith("'") && value.endsWith("'")