Fix e621 getAuthor() which could error out
authorNiki Roo <niki@nikiroo.be>
Wed, 15 Feb 2017 22:08:26 +0000 (23:08 +0100)
committerNiki Roo <niki@nikiroo.be>
Wed, 15 Feb 2017 22:08:26 +0000 (23:08 +0100)
src/be/nikiroo/fanfix/supported/E621.java

index cb4ae4657a7807c104cb5c7dbefe7324f015e9de..45c110f283ebaf825d5f7c65361917333f69add9 100644 (file)
@@ -96,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
                                        }
                                }
                        }