From: Niki Roo Date: Wed, 18 Sep 2019 20:34:31 +0000 (+0200) Subject: cbz: fix cover not copied from some file conversion X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=45994ba51196f76d4cb0fd0c8c9ea3458bf9a4f9;p=nikiroo-utils.git cbz: fix cover not copied from some file conversion --- 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