- public Story process(URL url) throws IOException {
- Story story = processMeta(url, false, true);
- story.setChapters(new ArrayList<Chapter>());
- Chapter chap = new Chapter(1, null);
- story.getChapters().add(chap);
-
- ZipInputStream zipIn = new ZipInputStream(getInput());
-
- List<String> images = new ArrayList<String>();
- 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;
+ public Story process(URL url, Progress pg) throws IOException {
+ if (pg == null) {
+ pg = new Progress();
+ } else {
+ pg.setMinMax(0, 100);
+ }
+
+ Progress pgMeta = new Progress();
+ pg.addProgress(pgMeta, 10);
+ Story story = processMeta(url, false, true, pgMeta);
+ pgMeta.done(); // 10%
+
+ File tmpDir = Instance.getTempFiles().createTempDir("info-text");
+ String basename = null;
+
+ Map<String, Image> images = new HashMap<String, Image>();
+ try {
+ 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) {
+ String uuid = meta.getUuid() + "_" + entry.getName();
+ try {
+ images.put(uuid, new Image(zipIn));
+ } catch (Exception e) {
+ Instance.getTraceHandler().error(e);
+ }
+
+ if (pg.getProgress() < 85) {
+ pg.add(1);
+ }
+ } else if (entryLName.endsWith(".info")) {
+ basename = entryLName.substring(0, entryLName.length()
+ - ".info".length());
+ IOUtils.write(zipIn, new File(tmpDir, entryLName));
+ } else if (entryLName.endsWith(".txt")) {
+ IOUtils.write(zipIn, new File(tmpDir, entryLName));