e621: author improvement
[nikiroo-utils.git] / supported / E621.java
index c3a261bd78af518da82b9b72c40eb088a2161026..a8ea6e6cf3df1b2bf82f4c1aedfea800f05851fe 100644 (file)
@@ -186,7 +186,7 @@ class E621 extends BasicSupport {
                                }
                                source = new URL(base + "/pools/" + poolNumber);
                        } catch (NumberFormatException e) {
-                               // Not a simple ppol, skip
+                               // Not a simple pool, skip
                        } catch (MalformedURLException e) {
                                // Cannot happen
                        }
@@ -247,19 +247,19 @@ class E621 extends BasicSupport {
                        title = el.text().trim();
                }
 
-               for (String s : new String[] { "e621", "-", "e621" }) {
+               for (String s : new String[] { "e621", "-", "e621", "Pool", "-" }) {
                        if (title.startsWith(s)) {
                                title = title.substring(s.length()).trim();
                        }
                        if (title.endsWith(s)) {
                                title = title.substring(0, title.length() - s.length()).trim();
                        }
-
                }
 
                if (isSearchOrSet(getSource())) {
                        title = title.isEmpty() ? "e621" : "[e621] " + title;
                }
+               
                return title;
        }
 
@@ -292,6 +292,28 @@ class E621 extends BasicSupport {
                                        builder.append(" ").append(tab[i]);
                                }
                        }
+
+                       if (builder.length() == 0) {
+                               try {
+                                       String poolNumber = getSource().getPath()
+                                                       .substring("/pools/".length());
+                                       String url = "https://e621.net/posts" + "?tags=pool%3A"
+                                                       + poolNumber;
+
+                                       Document page1 = DataUtil.load(Instance.getInstance()
+                                                       .getCache().open(getSource(), null, false), "UTF-8",
+                                                       url);
+                                       for (Element el : page1.getElementsByClass("search-tag")) {
+                                               if (el.attr("itemprop").equals("author")) {
+                                                       if (builder.length() > 0) {
+                                                               builder.append(", ");
+                                                       }
+                                                       builder.append(el.text().trim());
+                                               }
+                                       }
+                               } catch (Exception e) {
+                               }
+                       }
                }
 
                return builder.toString();