X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FInfoText.java;h=2af8c7e2f4880139540aa6f7f4e4895fd6e4742d;hb=a5d1f0e6320710cc4c8163adf2dc402e8f05fb96;hp=771d5102e8a10fb416747eaa18cb2339a75fc321;hpb=57f02339393c9997391b76ffcb22ae72fd0a45cb;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/supported/InfoText.java b/src/be/nikiroo/fanfix/supported/InfoText.java deleted file mode 100644 index 771d510..0000000 --- a/src/be/nikiroo/fanfix/supported/InfoText.java +++ /dev/null @@ -1,79 +0,0 @@ -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; - -/** - * Support class for .info text files ({@link Text} files with a - * .info metadata file next to them). - *

- * The .info file is supposed to be written by this program, or - * compatible. - * - * @author niki - */ -class InfoText extends Text { - @Override - public String getSourceName() { - return "info-text"; - } - - @Override - protected MetaData getMeta(URL source, InputStream in) throws IOException { - try { - MetaData meta = InfoReader.readMeta( - new File(new File(source.toURI()).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); - } - } - - @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; - } -}