Fix e621 getAuthor() which could error out
[fanfix.git] / src / be / nikiroo / fanfix / supported / E621.java
index bc6ba5b1501e83a1c1afbbdf38e6804d7147fdf7..45c110f283ebaf825d5f7c65361917333f69add9 100644 (file)
@@ -39,6 +39,7 @@ class E621 extends BasicSupport {
                meta.setDate("");
                meta.setTags(new ArrayList<String>()); // TODDO ???
                meta.setSource(getSourceName());
+               meta.setUrl(source.toString());
                meta.setPublisher(getSourceName());
                meta.setUuid(source.toString());
                meta.setLuid("");
@@ -95,24 +96,28 @@ class E621 extends BasicSupport {
                                        author = author.substring(0, pos - 1);
                                        String page = source.getProtocol() + "://"
                                                        + source.getHost() + author;
-                                       InputStream pageIn = Instance.getCache().open(
-                                                       new URL(page), this, false);
                                        try {
-                                               key = "class=\"tag-type-artist\"";
-                                               author = getLine(pageIn, key, 0);
-                                               if (author != null) {
-                                                       pos = author.indexOf("<a href=\"");
-                                                       if (pos >= 0) {
-                                                               author = author.substring(pos);
-                                                               pos = author.indexOf("</a>");
+                                               InputStream pageIn = Instance.getCache().open(
+                                                               new URL(page), this, false);
+                                               try {
+                                                       key = "class=\"tag-type-artist\"";
+                                                       author = getLine(pageIn, key, 0);
+                                                       if (author != null) {
+                                                               pos = author.indexOf("<a href=\"");
                                                                if (pos >= 0) {
-                                                                       author = author.substring(0, pos);
-                                                                       return StringUtils.unhtml(author);
+                                                                       author = author.substring(pos);
+                                                                       pos = author.indexOf("</a>");
+                                                                       if (pos >= 0) {
+                                                                               author = author.substring(0, pos);
+                                                                               return StringUtils.unhtml(author);
+                                                                       }
                                                                }
                                                        }
+                                               } finally {
+                                                       pageIn.close();
                                                }
-                                       } finally {
-                                               pageIn.close();
+                                       } catch (Exception e) {
+                                               // No author found
                                        }
                                }
                        }