From 2ece00882f9f140eab3f1e9657373692bc0cad7c Mon Sep 17 00:00:00 2001 From: soloturn Date: Sat, 18 Nov 2023 07:01:48 +0100 Subject: [PATCH] new URI instead of new URL, abstractjsonripper nextPage. --- .../java/com/rarchives/ripme/ripper/AbstractJSONRipper.java | 4 ++-- .../java/com/rarchives/ripme/ripper/rippers/DerpiRipper.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractJSONRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractJSONRipper.java index 2fbc05e17..538a4b5d6 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractJSONRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractJSONRipper.java @@ -38,7 +38,7 @@ protected AbstractJSONRipper(URL url) throws IOException { public abstract String getHost(); protected abstract JSONObject getFirstPage() throws IOException; - protected JSONObject getNextPage(JSONObject doc) throws IOException { + protected JSONObject getNextPage(JSONObject doc) throws IOException, URISyntaxException { throw new IOException("getNextPage not implemented"); } protected abstract List getURLsFromJSON(JSONObject json); @@ -104,7 +104,7 @@ public void rip() throws IOException { try { sendUpdate(STATUS.LOADING_RESOURCE, "next page"); json = getNextPage(json); - } catch (IOException e) { + } catch (IOException | URISyntaxException e) { LOGGER.info("Can't get next page: " + e.getMessage()); break; } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/DerpiRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/DerpiRipper.java index c2acdc56f..a05386146 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/DerpiRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/DerpiRipper.java @@ -101,10 +101,10 @@ public JSONObject getFirstPage() throws IOException { } @Override - public JSONObject getNextPage(JSONObject doc) throws IOException { + public JSONObject getNextPage(JSONObject doc) throws IOException, URISyntaxException { currPage++; String u = currUrl.toExternalForm() + "&page=" + Integer.toString(currPage); - JSONObject json = Http.url(new URL(u)).getJSON(); + JSONObject json = Http.url(new URI(u).toURL()).getJSON(); JSONArray arr; if (json.has("images")) { arr = json.getJSONArray("images");