From 431d382c5feb53949583acd66948f9a9fb7fb30c Mon Sep 17 00:00:00 2001 From: soloturn Date: Sun, 11 Apr 2021 19:17:06 +0200 Subject: [PATCH] remove DrawcrowdRipper, #24 --- .../ripme/ripper/rippers/DrawcrowdRipper.java | 91 ------------------- .../ripper/rippers/DrawcrowdRipperTest.java | 19 ---- 2 files changed, 110 deletions(-) delete mode 100644 src/main/java/com/rarchives/ripme/ripper/rippers/DrawcrowdRipper.java delete mode 100644 src/test/java/com/rarchives/ripme/tst/ripper/rippers/DrawcrowdRipperTest.java diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/DrawcrowdRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/DrawcrowdRipper.java deleted file mode 100644 index 521bc7c43..000000000 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/DrawcrowdRipper.java +++ /dev/null @@ -1,91 +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.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import com.rarchives.ripme.ripper.AbstractHTMLRipper; -import com.rarchives.ripme.utils.Http; - -public class DrawcrowdRipper extends AbstractHTMLRipper { - - public DrawcrowdRipper(URL url) throws IOException { - super(url); - } - - @Override - public String getHost() { - return "drawcrowd"; - } - @Override - public String getDomain() { - return "drawcrowd.com"; - } - - @Override - public String getGID(URL url) throws MalformedURLException { - Pattern p; Matcher m; - - p = Pattern.compile("^.*drawcrowd.com/projects/.*$"); - m = p.matcher(url.toExternalForm()); - if (m.matches()) { - throw new MalformedURLException("Cannot rip drawcrowd.com/projects/ pages"); - } - - p = Pattern.compile("^.*drawcrowd.com/([a-zA-Z0-9\\-_]+).*$"); - m = p.matcher(url.toExternalForm()); - if (m.matches()) { - return m.group(1); - } - - throw new MalformedURLException( - "Expected drawcrowd.com gallery format: " - + "drawcrowd.com/username" - + " Got: " + url); - } - - @Override - public Document getFirstPage() throws IOException { - return Http.url(this.url).get(); - } - - @Override - public Document getNextPage(Document doc) throws IOException { - Elements loadMore = doc.select("a#load-more"); - if (loadMore.isEmpty()) { - throw new IOException("No next page found"); - } - if (!sleep(1000)) { - throw new IOException("Interrupted while waiting for next page"); - } - String nextPage = "http://drawcrowd.com" + loadMore.get(0).attr("href"); - return Http.url(nextPage).get(); - } - - @Override - public List getURLsFromPage(Document page) { - List imageURLs = new ArrayList<>(); - for (Element thumb : page.select("div.item.asset img")) { - String image = thumb.attr("src"); - image = image - .replaceAll("/medium/", "/large/") - .replaceAll("/small/", "/large/"); - imageURLs.add(image); - } - return imageURLs; - } - - @Override - public void downloadURL(URL url, int index) { - addURLToDownload(url, getPrefix(index)); - } - -} \ No newline at end of file diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DrawcrowdRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DrawcrowdRipperTest.java deleted file mode 100644 index b326d365c..000000000 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DrawcrowdRipperTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.rarchives.ripme.tst.ripper.rippers; - -import java.io.IOException; -import java.net.URL; - -import com.rarchives.ripme.ripper.rippers.DrawcrowdRipper; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class DrawcrowdRipperTest extends RippersTest { - @Test - @Disabled("https://github.com/RipMeApp/ripme/issues/304 -- Drawcrowd broken (site changed)") - public void testRip() throws IOException { - DrawcrowdRipper ripper = new DrawcrowdRipper(new URL("https://drawcrowd.com/rabbiteyes")); - testRipper(ripper); - } - -}