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 public boolean isImageDocument(URL source
, InputStream in
)
50 protected boolean getCover() {
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 // we assume that we can get the UUID without a stream
78 String uuid
= getUuid(url
, null) + "_"
81 Instance
.getCache().addToCache(zipIn
, uuid
);
82 chap
.getParagraphs().add(
83 new Paragraph(new File(uuid
).toURI().toURL()));
84 } catch (Exception e
) {