e621: allow old urls for pools
authorNiki Roo <niki@nikiroo.be>
Thu, 2 Apr 2020 13:39:16 +0000 (15:39 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 2 Apr 2020 13:39:16 +0000 (15:39 +0200)
src/be/nikiroo/fanfix/supported/E621.java

index 316ac2c2bcfbad54411467af2f34713e37772d8d..4b2fb9028ba04c5ea50286eea031ebc445c39a34 100644 (file)
@@ -3,6 +3,7 @@ package be.nikiroo.fanfix.supported;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLDecoder;
 import java.util.AbstractMap;
@@ -170,6 +171,13 @@ class E621 extends BasicSupport {
                        }
                }
 
+               if (isPool(source)) {
+                       try {
+                               return new URL(source.toString().replace("/pool/show/", "/pools/"));
+                       } catch (MalformedURLException e) {
+                       }
+               }
+
                return super.getCanonicalUrl(source);
        }
 
@@ -287,7 +295,7 @@ class E621 extends BasicSupport {
        }
 
        private boolean isPool(URL url) {
-               return url.getPath().startsWith("/pools/");
+               return url.getPath().startsWith("/pools/") || url.getPath().startsWith("/pool/show/");
        }
 
        // set will be renamed into search by canonical url