X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FCbz.java;h=7fe496d97ea8acb9e8869bb41c37d6723e19a636;hb=8831d290121e3a77f535ce06d61968a26ccf172a;hp=012c0474a95df1a05cae162a9518e322f9099a80;hpb=08fe2e33007063e30fe22dc1d290f8afaa18eb1d;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/supported/Cbz.java b/src/be/nikiroo/fanfix/supported/Cbz.java deleted file mode 100644 index 012c047..0000000 --- a/src/be/nikiroo/fanfix/supported/Cbz.java +++ /dev/null @@ -1,93 +0,0 @@ -package be.nikiroo.fanfix.supported; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import be.nikiroo.fanfix.Instance; -import be.nikiroo.fanfix.data.Chapter; -import be.nikiroo.fanfix.data.Paragraph; -import be.nikiroo.fanfix.data.Story; - -/** - * Support class for CBZ files (works better with CBZ created with this program, - * as they have some metadata available). - * - * @author niki - */ -class Cbz extends Epub { - @Override - protected boolean supports(URL url) { - return url.toString().toLowerCase().endsWith(".cbz"); - } - - @Override - public String getSourceName() { - return "cbz"; - } - - @Override - protected String getDataPrefix() { - return ""; - } - - @Override - protected boolean requireInfo() { - return false; - } - - @Override - public boolean isImageDocument(URL source, InputStream in) - throws IOException { - return true; - } - - @Override - protected boolean getCover() { - return false; - } - - @Override - public Story process(URL url) throws IOException { - Story story = processMeta(url, false, true); - story.setChapters(new ArrayList()); - Chapter chap = new Chapter(1, null); - story.getChapters().add(chap); - - ZipInputStream zipIn = new ZipInputStream(getInput()); - - for (ZipEntry entry = zipIn.getNextEntry(); entry != null; entry = zipIn - .getNextEntry()) { - if (!entry.isDirectory() - && entry.getName().startsWith(getDataPrefix())) { - String entryLName = entry.getName().toLowerCase(); - boolean imageEntry = false; - for (String ext : getImageExt(false)) { - if (entryLName.endsWith(ext)) { - imageEntry = true; - } - } - - if (imageEntry) { - try { - // we assume that we can get the UUID without a stream - String uuid = getUuid(url, null) + "_" - + entry.getName(); - - Instance.getCache().addToCache(zipIn, uuid); - chap.getParagraphs().add( - new Paragraph(new File(uuid).toURI().toURL())); - } catch (Exception e) { - Instance.syserr(e); - } - } - } - } - - return story; - } -}