From 45994ba51196f76d4cb0fd0c8c9ea3458bf9a4f9 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Wed, 18 Sep 2019 22:34:31 +0200 Subject: [PATCH] cbz: fix cover not copied from some file conversion --- src/be/nikiroo/fanfix/supported/Cbz.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/be/nikiroo/fanfix/supported/Cbz.java b/src/be/nikiroo/fanfix/supported/Cbz.java index c7475fa..22e436a 100644 --- a/src/be/nikiroo/fanfix/supported/Cbz.java +++ b/src/be/nikiroo/fanfix/supported/Cbz.java @@ -13,6 +13,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import be.nikiroo.fanfix.Instance; +import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Paragraph; @@ -90,7 +91,7 @@ class Cbz extends Epub { imageEntry = true; } } - + if (imageEntry) { String uuid = meta.getUuid() + "_" + entry.getName(); try { @@ -111,6 +112,14 @@ class Cbz extends Epub { } } } + + String ext = "." + + Instance.getConfig() + .getString(Config.FILE_FORMAT_IMAGE_FORMAT_COVER) + .toLowerCase(); + String coverName = meta.getUuid() + "_" + basename + ext; + Image cover = images.get(coverName); + images.remove(coverName); pg.setProgress(85); @@ -120,7 +129,7 @@ class Cbz extends Epub { pg.setProgress(90); - // only the description is kept + // only the description/cover is kept Story origStory = getStoryFromTxt(tmpDir, basename); if (origStory != null) { if (origStory.getMeta().getCover() == null) { @@ -128,6 +137,9 @@ class Cbz extends Epub { } story.setMeta(origStory.getMeta()); } + if (story.getMeta().getCover() == null) { + story.getMeta().setCover(cover); + } story.setChapters(new ArrayList()); // Check if we can find non-images chapters, for hybrid-cbz support -- 2.27.0