- protected void preprocess(URL source, InputStream in) throws IOException {
- // Note: do NOT close this stream, as it would also close "in"
- ZipInputStream zipIn = new ZipInputStream(in);
- tmp = File.createTempFile("fanfic-reader-parser_", ".tmp");
- File tmpInfo = new File(tmp + ".info");
- fakeSource = tmp.toURI().toURL();
- BufferedImage cover = null;
-
- 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;
+ protected Document loadDocument(URL source) throws IOException {
+ super.loadDocument(source); // prepares super.getSourceFile() and
+ // super.getInput()
+
+ InputStream in = super.getInput();
+ ZipInputStream zipIn = null;
+ try {
+ zipIn = new ZipInputStream(in);
+ tmpDir = Instance.getInstance().getTempFiles()
+ .createTempDir("fanfic-reader-parser");
+ File tmp = new File(tmpDir, "file.txt");
+ File tmpInfo = new File(tmpDir, "file.info");
+
+ fakeSource = tmp.toURI().toURL();
+ Image cover = null;
+
+ String url;
+ try {
+ url = getSource().toURI().toURL().toString();
+ } catch (URISyntaxException e1) {
+ url = getSource().toString();
+ }
+ String title = null;
+ String author = null;
+
+ for (ZipEntry entry = zipIn
+ .getNextEntry(); entry != null; entry = zipIn
+ .getNextEntry()) {
+ if (!entry.isDirectory()
+ && entry.getName().startsWith(getDataPrefix())) {
+ String entryLName = entry.getName().toLowerCase();
+ entryLName = entryLName.substring(getDataPrefix().length());
+
+ boolean imageEntry = false;
+ for (String ext : bsImages.getImageExt(false)) {
+ if (entryLName.endsWith(ext)) {
+ imageEntry = true;
+ }