From dfcc791720b68a6fcf1055d7faa202fd31e057e4 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Fri, 1 May 2020 12:56:21 +0200 Subject: [PATCH] e621: fix search-pool urls --- src/be/nikiroo/fanfix/supported/E621.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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()); -- 2.27.0