ImgScroll/src/main/java/com/rarchives/ripme/ripper/rippers/ButttoucherRipper.java

70 lines
1.8 KiB
Java
Raw Normal View History

2014-04-21 08:20:16 +02:00
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;
2014-04-21 08:20:16 +02:00
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
2014-06-23 04:17:40 +02:00
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
import com.rarchives.ripme.utils.Http;
2014-04-21 08:20:16 +02:00
2014-06-23 04:17:40 +02:00
public class ButttoucherRipper extends AbstractHTMLRipper {
2014-04-21 08:20:16 +02:00
public ButttoucherRipper(URL url) throws IOException {
super(url);
}
@Override
public String getHost() {
return "butttoucher";
2014-04-21 08:20:16 +02:00
}
@Override
public String getDomain() {
return "butttoucher.com";
}
2014-04-21 08:20:16 +02:00
@Override
public String getGID(URL url) throws MalformedURLException {
Pattern p; Matcher m;
p = Pattern.compile("^.*butttoucher.com/users/([a-zA-Z0-9_\\-]{1,}).*$");
m = p.matcher(url.toExternalForm());
if (m.matches()) {
return m.group(1);
}
throw new MalformedURLException(
"Expected butttoucher.com gallery format: "
+ "butttoucher.com/users/<username>"
+ " Got: " + url);
}
@Override
public Document getFirstPage() throws IOException {
return Http.url(this.url).get();
}
@Override
public List<String> getURLsFromPage(Document page) {
List<String> thumbs = new ArrayList<String>();
2014-07-25 08:09:51 +02:00
for (Element thumb : page.select(".thumb img")) {
2014-04-21 08:20:16 +02:00
if (!thumb.hasAttr("src")) {
continue;
}
String smallImage = thumb.attr("src");
thumbs.add(smallImage.replace("m.", "."));
2014-04-21 08:20:16 +02:00
}
return thumbs;
2014-04-21 08:20:16 +02:00
}
@Override
public void downloadURL(URL url, int index) {
addURLToDownload(url, getPrefix(index));
2014-04-21 08:20:16 +02:00
}
}