X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FInfoText.java;h=2af8c7e2f4880139540aa6f7f4e4895fd6e4742d;hb=d9691f01bac1ea36d234f240534ae8bb94ab522a;hp=5488ab0648f1e42c6ba476c921b9be9be6bf41d6;hpb=86d49dbc7c3eca665b7823b5de49bb73a31c7722;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/supported/InfoText.java b/src/be/nikiroo/fanfix/supported/InfoText.java index 5488ab0..2af8c7e 100644 --- a/src/be/nikiroo/fanfix/supported/InfoText.java +++ b/src/be/nikiroo/fanfix/supported/InfoText.java @@ -2,8 +2,6 @@ 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.data.MetaData; @@ -18,46 +16,13 @@ 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 { - File sourceFile = new File(source.toURI()); - sourceFile = assureNoTxt(sourceFile); - - MetaData meta = InfoReader.readMeta(new File(sourceFile.getPath() - + ".info"), 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(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()); - } - 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); - } + protected MetaData getMeta() throws IOException { + return InfoReader.readMeta(getInfoFile(), true); } @Override