X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FInfoText.java;h=42e2c13b6f75a1e32afa10f560361c1670ea9572;hb=727108fef9dcc661d45fa69ebf8b76f5128a2b6f;hp=4f1dc39df95fae4ed24cf51f2908bc741813e947;hpb=68686a37a591a767f6d1af428ea0d5f3d3a1ddc1;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/supported/InfoText.java b/src/be/nikiroo/fanfix/supported/InfoText.java index 4f1dc39..42e2c13 100644 --- a/src/be/nikiroo/fanfix/supported/InfoText.java +++ b/src/be/nikiroo/fanfix/supported/InfoText.java @@ -2,11 +2,8 @@ package be.nikiroo.fanfix.supported; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; import java.net.URL; -import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.data.MetaData; /** @@ -19,56 +16,40 @@ import be.nikiroo.fanfix.data.MetaData; * @author niki */ class InfoText extends Text { - @Override - public String getSourceName() { - return "info-text"; + protected File getInfoFile() { + return new File(assureNoTxt(getSourceFile()).getPath() + ".info"); } @Override - protected MetaData getMeta(URL source, InputStream in) throws IOException { - try { - MetaData meta = InfoReader.readMeta(new File(new File(source - .toURI()).getPath() + ".info")); - - // Some old .info files don't have this information... - String test = meta.getTitle() == null ? "" : meta.getTitle(); - test += meta.getAuthor() == null ? "" : meta.getAuthor(); - test += meta.getDate() == null ? "" : meta.getDate(); - if (test.isEmpty()) { - MetaData superMeta = super.getMeta(source, reset(in)); - if (meta.getTitle() == null || meta.getTitle().isEmpty()) { - meta.setTitle(superMeta.getTitle()); - } - if (meta.getAuthor() == null || meta.getAuthor().isEmpty()) { - meta.setAuthor(superMeta.getAuthor()); - } - if (meta.getDate() == null || meta.getDate().isEmpty()) { - meta.setDate(superMeta.getDate()); - } + protected MetaData getMeta() throws IOException { + MetaData meta = InfoReader.readMeta(getInfoFile(), true); + + // Some old .info files don't have those now required fields... + String test = meta.getTitle() == null ? "" : meta.getTitle(); + test += meta.getAuthor() == null ? "" : meta.getAuthor(); + test += meta.getDate() == null ? "" : meta.getDate(); + test += meta.getUrl() == null ? "" : meta.getUrl(); + if (test.isEmpty()) { + MetaData superMeta = super.getMeta(); + if (meta.getTitle() == null || meta.getTitle().isEmpty()) { + meta.setTitle(superMeta.getTitle()); + } + if (meta.getAuthor() == null || meta.getAuthor().isEmpty()) { + meta.setAuthor(superMeta.getAuthor()); + } + if (meta.getDate() == null || meta.getDate().isEmpty()) { + meta.setDate(superMeta.getDate()); + } + if (meta.getUrl() == null || meta.getUrl().isEmpty()) { + meta.setUrl(superMeta.getUrl()); } - - return meta; - - } catch (URISyntaxException e) { - throw new IOException("Cannot parse URL to file: " + source, e); } + + return meta; } @Override protected boolean supports(URL url) { - if ("file".equals(url.getProtocol())) { - File file; - try { - file = new File(url.toURI()); - file = new File(file.getPath() + ".info"); - } catch (URISyntaxException e) { - Instance.syserr(e); - file = null; - } - - return file != null && file.exists(); - } - - return false; + return supports(url, true); } }