From 81bbcaba2c6227a7b7fb0553271044c52bbf09e1 Mon Sep 17 00:00:00 2001 From: 4pr0n Date: Sat, 10 May 2014 23:43:22 -0700 Subject: [PATCH] Added supertangas ripper #8 --- pom.xml | 2 +- .../ripper/rippers/SupertangasRipper.java | 96 +++++++++++++++++++ .../com/rarchives/ripme/ui/UpdateUtils.java | 2 +- 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/rarchives/ripme/ripper/rippers/SupertangasRipper.java diff --git a/pom.xml b/pom.xml index e0ab274f..9c72e38e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.0.36 + 1.0.37 ripme http://rip.rarchives.com diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/SupertangasRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/SupertangasRipper.java new file mode 100644 index 00000000..6f2faf7d --- /dev/null +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/SupertangasRipper.java @@ -0,0 +1,96 @@ +package com.rarchives.ripme.ripper.rippers; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.log4j.Logger; +import org.jsoup.HttpStatusException; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.ui.RipStatusMessage.STATUS; + +public class SupertangasRipper extends AlbumRipper { + + private static final String DOMAIN = "supertangas.com", + HOST = "supertangas"; + private static final Logger logger = Logger.getLogger(SupertangasRipper.class); + + public SupertangasRipper(URL url) throws IOException { + super(url); + } + + @Override + public boolean canRip(URL url) { + return url.getHost().endsWith(DOMAIN); + } + + @Override + public URL sanitizeURL(URL url) throws MalformedURLException { + return url; + } + + @Override + public void rip() throws IOException { + int page = 0; + String baseURL = "http://www.supertangas.com/fotos/?level=search&exact=1&searchterms=" + this.getGID(this.url); + Document doc; + while (true) { + page++; + String theURL = baseURL; + if (page > 1) { + theURL += "&plog_page=" + page; + } + try { + logger.info(" Retrieving " + theURL); + sendUpdate(STATUS.LOADING_RESOURCE, theURL); + doc = Jsoup.connect(theURL) + .userAgent(USER_AGENT) + .timeout(5 * 1000) + .get(); + } catch (HttpStatusException e) { + logger.debug("Hit end of pages at page " + page, e); + break; + } + Elements images = doc.select("li.thumbnail a"); + if (images.size() == 0) { + break; + } + for (Element imageElement : images) { + String image = imageElement.attr("href"); + image = image.replaceAll("\\/fotos\\/", "/fotos/images/"); + addURLToDownload(new URL(image)); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + logger.error("[!] Interrupted while waiting to load next page", e); + break; + } + } + waitForThreads(); + } + + @Override + public String getHost() { + return HOST; + } + + @Override + public String getGID(URL url) throws MalformedURLException { + // http://www.supertangas.com/fotos/?level=search&exact=1&searchterms=Tahiticora%20(France) + Pattern p = Pattern.compile("^https?://[w.]*supertangas\\.com/fotos/\\?.*&searchterms=([a-zA-Z0-9%()+]+).*$"); + Matcher m = p.matcher(url.toExternalForm()); + if (!m.matches()) { + throw new MalformedURLException("Expected format: http://supertangas.com/fotos/?level=search&exact=1&searchterms=..."); + } + return m.group(m.groupCount()); + } + +} diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index b62ad0db..c0374a5e 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils; public class UpdateUtils { private static final Logger logger = Logger.getLogger(UpdateUtils.class); - private static final String DEFAULT_VERSION = "1.0.36"; + private static final String DEFAULT_VERSION = "1.0.37"; private static final String updateJsonURL = "http://rarchives.com/ripme.json"; private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String mainFileName = "ripme.jar";