Continue conversion test + HTML.supports() fix
[nikiroo-utils.git] / src / be / nikiroo / fanfix / supported / InfoText.java
index 4f1dc39df95fae4ed24cf51f2908bc741813e947..5488ab0648f1e42c6ba476c921b9be9be6bf41d6 100644 (file)
@@ -6,7 +6,6 @@ import java.io.InputStream;
 import java.net.URISyntaxException;
 import java.net.URL;
 
-import be.nikiroo.fanfix.Instance;
 import be.nikiroo.fanfix.data.MetaData;
 
 /**
@@ -27,13 +26,17 @@ class InfoText extends Text {
        @Override
        protected MetaData getMeta(URL source, InputStream in) throws IOException {
                try {
-                       MetaData meta = InfoReader.readMeta(new File(new File(source
-                                       .toURI()).getPath() + ".info"));
+                       File sourceFile = new File(source.toURI());
+                       sourceFile = assureNoTxt(sourceFile);
 
-                       // Some old .info files don't have this information...
+                       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()) {
@@ -45,6 +48,9 @@ class InfoText extends Text {
                                if (meta.getDate() == null || meta.getDate().isEmpty()) {
                                        meta.setDate(superMeta.getDate());
                                }
+                               if (meta.getUrl() == null || meta.getUrl().isEmpty()) {
+                                       meta.setUrl(superMeta.getUrl());
+                               }
                        }
 
                        return meta;
@@ -56,19 +62,6 @@ class InfoText extends Text {
 
        @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);
        }
 }