private boolean imageDocument;
private long words;
private String creationDate;
+ private boolean fakeCover;
/**
* The title of the story.
this.creationDate = creationDate;
}
+ /**
+ * The cover in this {@link MetaData} object is "fake", in the sens that it
+ * comes from the actual content images.
+ *
+ * @return TRUE for a fake cover
+ */
+ public boolean isFakeCover() {
+ return fakeCover;
+ }
+
+ /**
+ * The cover in this {@link MetaData} object is "fake", in the sens that it
+ * comes from the actual content images
+ *
+ * @param fakeCover
+ * TRUE for a fake cover
+ */
+ public void setFakeCover(boolean fakeCover) {
+ this.fakeCover = fakeCover;
+ }
+
public int compareTo(MetaData o) {
String oUuid = o == null ? null : o.getUuid();
return getUuid().compareTo(oUuid);
// will also save the images!
new InfoText().process(story, dir, targetNameOrig);
+
InfoCover.writeInfo(dir, targetNameOrig, story.getMeta());
- InfoCover.writeCover(dir, targetNameOrig, story.getMeta());
+ if (story.getMeta() != null && !story.getMeta().isFakeCover()) {
+ InfoCover.writeCover(dir, targetNameOrig, story.getMeta());
+ }
IOUtils.writeSmallFile(dir, "version", "3.0");
writeMeta(infoWriter, "WORDCOUNT",
Long.toString(meta.getWords()));
writeMeta(infoWriter, "CREATION_DATE", meta.getCreationDate());
+ writeMeta(infoWriter, "FAKE_COVER",
+ Boolean.toString(meta.isFakeCover()));
} finally {
infoWriter.close();
}
package be.nikiroo.fanfix.supported;
+import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import javax.imageio.ImageIO;
+
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.data.Chapter;
import be.nikiroo.fanfix.data.Paragraph;
if (imageEntry) {
String uuid = meta.getUuid() + "_" + entry.getName();
- images.add(uuid);
try {
- Instance.getCache().addToCache(zipIn, uuid);
+ File tmp = Instance.getCache().addToCache(zipIn, uuid);
+ images.add(tmp.toURI().toURL().toString());
} catch (Exception e) {
Instance.syserr(e);
}
pg.setProgress(80);
- // ZIP order is not sure
+ // ZIP order is not correct for us
Collections.sort(images);
pg.setProgress(90);
for (String uuid : images) {
try {
- chap.getParagraphs().add(
- new Paragraph(new File(uuid).toURI().toURL()));
+ chap.getParagraphs().add(new Paragraph(new URL(uuid)));
} catch (Exception e) {
Instance.syserr(e);
}
}
+ if (meta.getCover() == null && !images.isEmpty()) {
+ InputStream in = Instance.getCache().open(new URL(images.get(0)),
+ this, true);
+ try {
+ BufferedImage fcover = ImageIO.read(in);
+ meta.setCover(fcover);
+ meta.setFakeCover(true);
+ } finally {
+ in.close();
+ }
+ }
+
pg.setProgress(100);
return story;
}
meta.setType(getType().toString());
meta.setImageDocument(true);
meta.setCover(getCover(source));
+ meta.setFakeCover(true);
return meta;
}
meta.setWords(0);
}
meta.setCreationDate(getInfoTag(in, "CREATION_DATE"));
+ meta.setFakeCover(Boolean.parseBoolean(getInfoTag(in, "FAKE_COVER")));
if (meta.getCover() == null) {
meta.setCover(BasicSupport.getDefaultCover(meta.getSubject()));