f9eee08d51428cab98f2c3fbe9b6561cd3087f56
1 package be
.nikiroo
.fanfix
.supported
;
4 import java
.io
.IOException
;
5 import java
.io
.InputStream
;
7 import java
.util
.ArrayList
;
8 import java
.util
.zip
.ZipEntry
;
9 import java
.util
.zip
.ZipInputStream
;
11 import be
.nikiroo
.fanfix
.Instance
;
12 import be
.nikiroo
.fanfix
.data
.Chapter
;
13 import be
.nikiroo
.fanfix
.data
.Paragraph
;
14 import be
.nikiroo
.fanfix
.data
.Story
;
17 * Support class for CBZ files (works better with CBZ created with this program,
18 * as they have some metadata available).
22 class Cbz
extends Epub
{
24 protected boolean supports(URL url
) {
25 return url
.toString().toLowerCase().endsWith(".cbz");
29 public String
getSourceName() {
34 protected String
getDataPrefix() {
39 protected boolean requireInfo() {
44 protected boolean getCover() {
49 protected void preprocess(URL source
, InputStream in
) throws IOException
{
50 super.preprocess(source
, in
);
51 meta
.setImageDocument(true);
55 public Story
process(URL url
) throws IOException
{
56 Story story
= processMeta(url
, false, true);
57 story
.setChapters(new ArrayList
<Chapter
>());
58 Chapter chap
= new Chapter(1, null);
59 story
.getChapters().add(chap
);
61 ZipInputStream zipIn
= new ZipInputStream(getInput());
63 for (ZipEntry entry
= zipIn
.getNextEntry(); entry
!= null; entry
= zipIn
65 if (!entry
.isDirectory()
66 && entry
.getName().startsWith(getDataPrefix())) {
67 String entryLName
= entry
.getName().toLowerCase();
68 boolean imageEntry
= false;
69 for (String ext
: getImageExt(false)) {
70 if (entryLName
.endsWith(ext
)) {
77 String uuid
= meta
.getUuid() + "_" + entry
.getName();
79 Instance
.getCache().addToCache(zipIn
, uuid
);
80 chap
.getParagraphs().add(
81 new Paragraph(new File(uuid
).toURI().toURL()));
82 } catch (Exception e
) {