From dffe9a40aa536758ef9edc9dd58e47b6c14f4d77 Mon Sep 17 00:00:00 2001 From: metaprime Date: Tue, 21 Nov 2017 02:02:26 -0800 Subject: [PATCH] ImageStash.com is permanently down: remove ImagestashRipper --- .../ripper/rippers/ImagestashRipper.java | 87 ------------------- .../ripper/rippers/ImagestashRipperTest.java | 15 ---- 2 files changed, 102 deletions(-) delete mode 100644 src/main/java/com/rarchives/ripme/ripper/rippers/ImagestashRipper.java delete mode 100644 src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagestashRipperTest.java diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ImagestashRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ImagestashRipper.java deleted file mode 100644 index c8cc3d74..00000000 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ImagestashRipper.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.rarchives.ripme.ripper.rippers; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.json.JSONArray; -import org.json.JSONObject; - -import com.rarchives.ripme.ripper.AbstractJSONRipper; -import com.rarchives.ripme.utils.Http; - -public class ImagestashRipper extends AbstractJSONRipper { - - private int page = 1; - - public ImagestashRipper(URL url) throws IOException { - super(url); - } - - @Override - public String getHost() { - return "imagestash"; - } - @Override - public String getDomain() { - return "imagestash.org"; - } - - @Override - public String getGID(URL url) throws MalformedURLException { - Pattern p = Pattern.compile("^.*imagestash.org/tag/([a-zA-Z0-9\\-_]+)$"); - Matcher m = p.matcher(url.toExternalForm()); - if (m.matches()) { - return m.group(1); - } - throw new MalformedURLException( - "Expected imagestash.org tag formats: " - + "imagestash.org/tag/tagname" - + " Got: " + url); - } - - @Override - public JSONObject getFirstPage() throws IOException { - String baseURL = "https://imagestash.org/images?tags=" - + getGID(url) - + "&page=" + page; - return Http.url(baseURL).getJSON(); - } - - @Override - public JSONObject getNextPage(JSONObject json) throws IOException { - int count = json.getInt("count"), - offset = json.getInt("offset"), - total = json.getInt("total"); - if (count + offset >= total || json.getJSONArray("images").length() == 0) { - throw new IOException("No more images"); - } - sleep(1000); - page++; - return getFirstPage(); - } - - @Override - public List getURLsFromJSON(JSONObject json) { - List imageURLs = new ArrayList<>(); - JSONArray images = json.getJSONArray("images"); - for (int i = 0; i < images.length(); i++) { - JSONObject image = images.getJSONObject(i); - String imageURL = image.getString("src"); - if (imageURL.startsWith("/")) { - imageURL = "https://imagestash.org" + imageURL; - } - imageURLs.add(imageURL); - } - return imageURLs; - } - - @Override - public void downloadURL(URL url, int index) { - addURLToDownload(url, getPrefix(index)); - } -} diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagestashRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagestashRipperTest.java deleted file mode 100644 index f6776ef2..00000000 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagestashRipperTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.rarchives.ripme.tst.ripper.rippers; - -import java.io.IOException; -import java.net.URL; - -import com.rarchives.ripme.ripper.rippers.ImagestashRipper; - -public class ImagestashRipperTest extends RippersTest { - /* - public void testImagestashRip() throws IOException { - ImagestashRipper ripper = new ImagestashRipper(new URL("https://imagestash.org/tag/everydayuncensor")); - testRipper(ripper); - } - */ -}