X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FLibrary.java;h=a120df1a09c850bab29338736b587ffac9a5767b;hp=9864ad773d085527c28e1dba467bf7a01be6ca1b;hb=fe999aa400c2627291325558f1ae8c734da7900c;hpb=08fe2e33007063e30fe22dc1d290f8afaa18eb1d diff --git a/src/be/nikiroo/fanfix/Library.java b/src/be/nikiroo/fanfix/Library.java index 9864ad7..a120df1 100644 --- a/src/be/nikiroo/fanfix/Library.java +++ b/src/be/nikiroo/fanfix/Library.java @@ -28,8 +28,6 @@ import be.nikiroo.fanfix.supported.BasicSupport.SupportType; public class Library { private File baseDir; private Map stories; - private BasicSupport itSupport = BasicSupport - .getSupport(SupportType.INFO_TEXT); private int lastId; /** @@ -82,8 +80,15 @@ public class Library { for (Entry entry : getStories().entrySet()) { if (luid.equals(entry.getKey().getLuid())) { try { - return itSupport.process(entry.getValue().toURI() - .toURL()); + SupportType type = SupportType.valueOfAllOkUC(entry + .getKey().getType()); + URL url = entry.getValue().toURI().toURL(); + if (type != null) { + return BasicSupport.getSupport(type).process(url); + } else { + throw new IOException("Unknown type: " + + entry.getKey().getType()); + } } catch (IOException e) { // We should not have not-supported files in the // library @@ -219,8 +224,9 @@ public class Library { private Map getStories() { if (stories.isEmpty()) { lastId = 0; - String format = Instance.getConfig() - .getString(Config.IMAGE_FORMAT_COVER).toLowerCase(); + String format = "." + + Instance.getConfig().getString(Config.IMAGE_FORMAT_COVER) + .toLowerCase(); for (File dir : baseDir.listFiles()) { if (dir.isDirectory()) { for (File file : dir.listFiles()) { @@ -228,20 +234,36 @@ public class Library { String path = file.getPath().toLowerCase(); if (!path.endsWith(".info") && !path.endsWith(format)) { - MetaData meta = itSupport.processMeta( + // TODO: export .info reading to a class and use + // it here + SupportType type = SupportType.INFO_TEXT; + if (path.toLowerCase().endsWith(".cbz")) { + type = SupportType.CBZ; + } + BasicSupport support = BasicSupport + .getSupport(type); + MetaData meta = support.processMeta( file.toURI().toURL()).getMeta(); - stories.put(meta, file); - - try { - int id = Integer.parseInt(meta.getLuid()); - if (id > lastId) { - lastId = id; + if (meta != null) { + stories.put(meta, file); + try { + int id = Integer.parseInt(meta + .getLuid()); + if (id > lastId) { + lastId = id; + } + } catch (Exception e) { + // not normal!! + Instance.syserr(new IOException( + "Cannot understand the LUID of " + + file.getPath() + ": " + + meta.getLuid(), e)); } - } catch (Exception e) { + } else { // not normal!! Instance.syserr(new IOException( - "Cannot read the LUID of: " - + file.getPath(), e)); + "Cannot get metadata for: " + + file.getPath())); } } } catch (IOException e) {