From 778d8d85f288c7b67c1a5156e5aedfc944997be0 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 26 Nov 2017 21:39:34 +0100 Subject: [PATCH] Fix name of imported cbz, fix library check --- changelog.md | 1 + src/be/nikiroo/fanfix/Instance.java | 17 +++++++++++------ src/be/nikiroo/fanfix/reader/GuiReader.java | 1 - src/be/nikiroo/fanfix/supported/Epub.java | 9 +++++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index 8449338..d36c87f 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ - Bug fixes - Remote server/client improvements +- Better support for some CBZ files (if SUMMARY or URL files are present in it) ## Version 1.6.2 diff --git a/src/be/nikiroo/fanfix/Instance.java b/src/be/nikiroo/fanfix/Instance.java index c48b119..97e9868 100644 --- a/src/be/nikiroo/fanfix/Instance.java +++ b/src/be/nikiroo/fanfix/Instance.java @@ -82,12 +82,6 @@ public class Instance { uiconfig = new UiConfigBundle(); trans = new StringIdBundle(getLang()); - try { - lib = new LocalLibrary(getFile(Config.LIBRARY_DIR)); - } catch (Exception e) { - syserr(new IOException("Cannot create library for directory: " - + getFile(Config.LIBRARY_DIR), e)); - } boolean debug = Instance.getConfig() .getBoolean(Config.DEBUG_ERR, false); @@ -110,6 +104,13 @@ public class Instance { tracer.setShowErrorDetails(debug); tracer.setShowTraces(trace); + try { + lib = new LocalLibrary(getFile(Config.LIBRARY_DIR)); + } catch (Exception e) { + syserr(new IOException("Cannot create library for directory: " + + getFile(Config.LIBRARY_DIR), e)); + } + // Could have used: System.getProperty("java.io.tmpdir") if (tmp == null) { tmp = new File(configDir, "tmp"); @@ -200,6 +201,10 @@ public class Instance { * @return the {@link LocalLibrary} */ public static BasicLibrary getLibrary() { + if (lib == null) { + throw new NullPointerException("We don't have a library to return"); + } + return lib; } diff --git a/src/be/nikiroo/fanfix/reader/GuiReader.java b/src/be/nikiroo/fanfix/reader/GuiReader.java index 8ff9d92..9353794 100644 --- a/src/be/nikiroo/fanfix/reader/GuiReader.java +++ b/src/be/nikiroo/fanfix/reader/GuiReader.java @@ -18,7 +18,6 @@ import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.library.BasicLibrary; import be.nikiroo.fanfix.library.CacheLibrary; -import be.nikiroo.fanfix.library.LocalLibrary; import be.nikiroo.utils.Progress; import be.nikiroo.utils.Version; import be.nikiroo.utils.ui.UIUtils; diff --git a/src/be/nikiroo/fanfix/supported/Epub.java b/src/be/nikiroo/fanfix/supported/Epub.java index 6819ec2..b8c4af0 100644 --- a/src/be/nikiroo/fanfix/supported/Epub.java +++ b/src/be/nikiroo/fanfix/supported/Epub.java @@ -6,6 +6,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; @@ -180,6 +181,14 @@ class Epub extends InfoText { } tmpInfo.delete(); } else { + if (title == null || title.isEmpty()) { + title = new File(source.getPath()).getName(); + if (title.toLowerCase().endsWith(".cbz")) { + title = title.substring(0, title.length() - 4); + } + title = URLDecoder.decode(title, "UTF-8").trim(); + } + meta = new MetaData(); meta.setLang("EN"); meta.setTags(new ArrayList()); -- 2.27.0