From 276f95c6ca9a79d2fc6879877b240cefb4ceb598 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 25 Mar 2018 11:46:45 +0200 Subject: [PATCH] Fix tests: - language upper/lower case - "TYPE=" in info files not always correct --- src/be/nikiroo/fanfix/output/BasicOutput.java | 4 ++-- src/be/nikiroo/fanfix/output/Cbz.java | 10 +++++----- src/be/nikiroo/fanfix/output/Epub.java | 4 ++-- src/be/nikiroo/fanfix/output/Html.java | 12 ++++++------ src/be/nikiroo/fanfix/supported/E621.java | 2 +- src/be/nikiroo/fanfix/supported/EHentai.java | 6 +++--- src/be/nikiroo/fanfix/supported/Epub.java | 2 +- src/be/nikiroo/fanfix/supported/Fanfiction.java | 2 +- src/be/nikiroo/fanfix/supported/Fimfiction.java | 2 +- src/be/nikiroo/fanfix/supported/FimfictionApi.java | 2 +- src/be/nikiroo/fanfix/supported/MangaFox.java | 2 +- src/be/nikiroo/fanfix/supported/Text.java | 4 ++-- src/be/nikiroo/fanfix/supported/YiffStar.java | 2 +- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/be/nikiroo/fanfix/output/BasicOutput.java b/src/be/nikiroo/fanfix/output/BasicOutput.java index a1aedca..dc6fe51 100644 --- a/src/be/nikiroo/fanfix/output/BasicOutput.java +++ b/src/be/nikiroo/fanfix/output/BasicOutput.java @@ -336,10 +336,10 @@ public abstract class BasicOutput { story.getMeta().setType("" + getType()); } - if (writeCover) { + if (isWriteCover()) { InfoCover.writeCover(targetDir, targetName, story.getMeta()); } - if (writeInfo) { + if (isWriteInfo()) { InfoCover.writeInfo(targetDir, targetName, story.getMeta()); } diff --git a/src/be/nikiroo/fanfix/output/Cbz.java b/src/be/nikiroo/fanfix/output/Cbz.java index a84428c..4a89d9b 100644 --- a/src/be/nikiroo/fanfix/output/Cbz.java +++ b/src/be/nikiroo/fanfix/output/Cbz.java @@ -33,6 +33,11 @@ class Cbz extends BasicOutput { .setType(OutputType.TEXT, isWriteInfo(), false) .process(story, dir, targetNameOrig); + try { + super.process(story, targetDir, targetNameOrig); + } finally { + } + InfoCover.writeInfo(dir, targetNameOrig, story.getMeta()); if (story.getMeta() != null && !story.getMeta().isFakeCover()) { InfoCover.writeCover(dir, targetNameOrig, story.getMeta()); @@ -40,11 +45,6 @@ class Cbz extends BasicOutput { IOUtils.writeSmallFile(dir, "version", "3.0"); - try { - super.process(story, targetDir, targetNameOrig); - } finally { - } - IOUtils.zip(dir, target, true); } finally { IOUtils.deltree(dir); diff --git a/src/be/nikiroo/fanfix/output/Epub.java b/src/be/nikiroo/fanfix/output/Epub.java index 2129758..64797d3 100644 --- a/src/be/nikiroo/fanfix/output/Epub.java +++ b/src/be/nikiroo/fanfix/output/Epub.java @@ -44,6 +44,8 @@ class Epub extends BasicOutput { "Cannot create a temporary directory: no space left on device?"); } + super.process(story, targetDir, targetNameOrig); + // "Originals" File data = new File(tmpDir, "DATA"); data.mkdir(); @@ -52,8 +54,6 @@ class Epub extends BasicOutput { InfoCover.writeInfo(data, targetNameOrig, story.getMeta()); IOUtils.writeSmallFile(data, "version", "3.0"); - super.process(story, targetDir, targetNameOrig); - // zip/epub File epub = new File(targetDir, targetName); IOUtils.zip(tmpDir, epub, true); diff --git a/src/be/nikiroo/fanfix/output/Html.java b/src/be/nikiroo/fanfix/output/Html.java index e91c6f4..756eb8d 100644 --- a/src/be/nikiroo/fanfix/output/Html.java +++ b/src/be/nikiroo/fanfix/output/Html.java @@ -32,12 +32,6 @@ class Html extends BasicOutput { target.mkdir(); dir = target; - // write a copy of the originals inside - InfoCover.writeInfo(dir, targetName, story.getMeta()); - InfoCover.writeCover(dir, targetName, story.getMeta()); - BasicOutput.getOutput(OutputType.TEXT, isWriteInfo(), isWriteCover()) - .process(story, dir, targetNameOrig); - target = new File(targetDir, targetName + getDefaultExtension(true)); writer = new BufferedWriter(new OutputStreamWriter( @@ -49,6 +43,12 @@ class Html extends BasicOutput { writer = null; } + // write a copy of the originals inside + InfoCover.writeInfo(dir, targetName, story.getMeta()); + InfoCover.writeCover(dir, targetName, story.getMeta()); + BasicOutput.getOutput(OutputType.TEXT, isWriteInfo(), isWriteCover()) + .process(story, dir, targetNameOrig); + if (story.getMeta().getCover() != null) { Instance.getCache().saveAsImage(story.getMeta().getCover(), new File(dir, "cover"), true); diff --git a/src/be/nikiroo/fanfix/supported/E621.java b/src/be/nikiroo/fanfix/supported/E621.java index 5fe99a8..298ccf1 100644 --- a/src/be/nikiroo/fanfix/supported/E621.java +++ b/src/be/nikiroo/fanfix/supported/E621.java @@ -45,7 +45,7 @@ class E621 extends BasicSupport_Deprecated { meta.setPublisher(getSourceName()); meta.setUuid(source.toString()); meta.setLuid(""); - meta.setLang("EN"); + meta.setLang("en"); meta.setSubject("Furry"); meta.setType(getType().toString()); meta.setImageDocument(true); diff --git a/src/be/nikiroo/fanfix/supported/EHentai.java b/src/be/nikiroo/fanfix/supported/EHentai.java index 574ea06..2fe70d9 100644 --- a/src/be/nikiroo/fanfix/supported/EHentai.java +++ b/src/be/nikiroo/fanfix/supported/EHentai.java @@ -108,11 +108,11 @@ class EHentai extends BasicSupport_Deprecated { if (langLine != null) { langLine = StringUtils.unhtml(langLine).trim(); if (langLine.equalsIgnoreCase("English")) { - lang = "EN"; + lang = "en"; } else if (langLine.equalsIgnoreCase("Japanese")) { - lang = "JP"; + lang = "jp"; } else if (langLine.equalsIgnoreCase("French")) { - lang = "FR"; + lang = "fr"; } else { // TODO find the code? lang = langLine; diff --git a/src/be/nikiroo/fanfix/supported/Epub.java b/src/be/nikiroo/fanfix/supported/Epub.java index 8ae4c6c..ce9bd06 100644 --- a/src/be/nikiroo/fanfix/supported/Epub.java +++ b/src/be/nikiroo/fanfix/supported/Epub.java @@ -189,7 +189,7 @@ class Epub extends InfoText { } meta = new MetaData(); - meta.setLang("EN"); + meta.setLang("en"); meta.setTags(new ArrayList()); meta.setSource(getSourceName()); meta.setUuid(url); diff --git a/src/be/nikiroo/fanfix/supported/Fanfiction.java b/src/be/nikiroo/fanfix/supported/Fanfiction.java index 0feb964..4193fa0 100644 --- a/src/be/nikiroo/fanfix/supported/Fanfiction.java +++ b/src/be/nikiroo/fanfix/supported/Fanfiction.java @@ -49,7 +49,7 @@ class Fanfiction extends BasicSupport_Deprecated { meta.setPublisher(getSourceName()); meta.setUuid(source.toString()); meta.setLuid(""); - meta.setLang("EN"); + meta.setLang("en"); //TODO! meta.setSubject(getSubject(reset(in))); meta.setType(getType().toString()); meta.setImageDocument(false); diff --git a/src/be/nikiroo/fanfix/supported/Fimfiction.java b/src/be/nikiroo/fanfix/supported/Fimfiction.java index ed9c9ad..1f72031 100644 --- a/src/be/nikiroo/fanfix/supported/Fimfiction.java +++ b/src/be/nikiroo/fanfix/supported/Fimfiction.java @@ -47,7 +47,7 @@ class Fimfiction extends BasicSupport_Deprecated { meta.setPublisher(getSourceName()); meta.setUuid(source.toString()); meta.setLuid(""); - meta.setLang("EN"); + meta.setLang("en"); meta.setSubject("MLP"); meta.setType(getType().toString()); meta.setImageDocument(false); diff --git a/src/be/nikiroo/fanfix/supported/FimfictionApi.java b/src/be/nikiroo/fanfix/supported/FimfictionApi.java index 231405b..6ef8a2c 100644 --- a/src/be/nikiroo/fanfix/supported/FimfictionApi.java +++ b/src/be/nikiroo/fanfix/supported/FimfictionApi.java @@ -128,7 +128,7 @@ class FimfictionApi extends BasicSupport_Deprecated { meta.setPublisher(getSourceName()); meta.setUuid(source.toString()); meta.setLuid(""); - meta.setLang("EN"); + meta.setLang("en"); meta.setSubject("MLP"); meta.setType(getType().toString()); meta.setImageDocument(false); diff --git a/src/be/nikiroo/fanfix/supported/MangaFox.java b/src/be/nikiroo/fanfix/supported/MangaFox.java index 5abc47b..b6d3fe1 100644 --- a/src/be/nikiroo/fanfix/supported/MangaFox.java +++ b/src/be/nikiroo/fanfix/supported/MangaFox.java @@ -66,7 +66,7 @@ class MangaFox extends BasicSupport { meta.setPublisher(getSourceName()); meta.setUuid(getSource().toString()); meta.setLuid(""); - meta.setLang("EN"); + meta.setLang("en"); meta.setSubject("manga"); meta.setType(getType().toString()); meta.setImageDocument(true); diff --git a/src/be/nikiroo/fanfix/supported/Text.java b/src/be/nikiroo/fanfix/supported/Text.java index fb4a0ad..a610594 100644 --- a/src/be/nikiroo/fanfix/supported/Text.java +++ b/src/be/nikiroo/fanfix/supported/Text.java @@ -95,9 +95,9 @@ class Text extends BasicSupport_Deprecated { } if (lang == null) { - lang = "EN"; + lang = "en"; } else { - lang = lang.toUpperCase(); + lang = lang.toLowerCase(); } return lang; diff --git a/src/be/nikiroo/fanfix/supported/YiffStar.java b/src/be/nikiroo/fanfix/supported/YiffStar.java index ca331e5..2996ce9 100644 --- a/src/be/nikiroo/fanfix/supported/YiffStar.java +++ b/src/be/nikiroo/fanfix/supported/YiffStar.java @@ -44,7 +44,7 @@ class YiffStar extends BasicSupport_Deprecated { meta.setPublisher(getSourceName()); meta.setUuid(source.toString()); meta.setLuid(""); - meta.setLang("EN"); + meta.setLang("en"); meta.setSubject("Furry"); meta.setType(getType().toString()); meta.setImageDocument(false); -- 2.27.0