From: Niki Roo Date: Fri, 1 May 2020 10:56:21 +0000 (+0200) Subject: e621: fix search-pool urls X-Git-Tag: fanfix-swing-1.1.0~27 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=dfcc791720b68a6fcf1055d7faa202fd31e057e4;p=fanfix-swing.git e621: fix search-pool urls --- diff --git a/src/be/nikiroo/fanfix/supported/E621.java b/src/be/nikiroo/fanfix/supported/E621.java index 39bbe867..2b7e54d8 100644 --- a/src/be/nikiroo/fanfix/supported/E621.java +++ b/src/be/nikiroo/fanfix/supported/E621.java @@ -173,6 +173,25 @@ class E621 extends BasicSupport { @Override protected URL getCanonicalUrl(URL source) { + // Convert search-pools into proper pools + if (source.getPath().equals("/posts") && source.getQuery() != null + && source.getQuery().startsWith("tags=pool%3A")) { + String poolNumber = source.getQuery() + .substring("tags=pool%3A".length()); + try { + Integer.parseInt(poolNumber); + String base = source.getProtocol() + "://" + source.getHost(); + if (source.getPort() != -1) { + base = base + ":" + source.getPort(); + } + source = new URL(base + "/posts/" + poolNumber); + } catch (NumberFormatException e) { + // Not a simple ppol, skip + } catch (MalformedURLException e) { + // Cannot happen + } + } + if (isSetOriginalUrl(source)) { try { Document doc = DataUtil.load(Instance.getInstance().getCache().open(source, this, false), "UTF-8", source.toString());