From: Niki Roo Date: Fri, 1 May 2020 10:56:21 +0000 (+0200) Subject: e621: fix search-pool urls X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=8fbfa934ae7ba906019e9b51e4c8a8acc1b793c9;p=nikiroo-utils.git e621: fix search-pool urls --- diff --git a/supported/E621.java b/supported/E621.java index 39bbe86..2b7e54d 100644 --- a/supported/E621.java +++ b/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());