2014-05-17 17:52:00 +02:00
|
|
|
package com.rarchives.ripme.ripper.rippers;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
2017-11-11 09:10:08 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2014-05-17 17:52:00 +02:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
import org.jsoup.nodes.Document;
|
2017-11-11 09:10:08 +01:00
|
|
|
import org.jsoup.nodes.Element;
|
2014-05-17 17:52:00 +02:00
|
|
|
|
2017-11-11 09:10:08 +01:00
|
|
|
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
|
|
|
import com.rarchives.ripme.utils.Http;
|
2014-05-17 17:52:00 +02:00
|
|
|
|
2017-11-11 09:10:08 +01:00
|
|
|
public class ModelmayhemRipper extends AbstractHTMLRipper {
|
2014-05-17 17:52:00 +02:00
|
|
|
|
|
|
|
public ModelmayhemRipper(URL url) throws IOException {
|
|
|
|
super(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-11-11 09:10:08 +01:00
|
|
|
public String getHost() {
|
|
|
|
return "modelmayhem";
|
2014-05-17 17:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-11-11 09:10:08 +01:00
|
|
|
public String getDomain() {
|
|
|
|
return "modelmayhem.com";
|
2014-05-17 17:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-11-11 09:10:08 +01:00
|
|
|
public String getGID(URL url) throws MalformedURLException {
|
|
|
|
Pattern p = Pattern.compile("https?://www\\.modelmayhem\\.com/portfolio/(\\d+)/viewall");
|
|
|
|
Matcher m = p.matcher(url.toExternalForm());
|
|
|
|
if (m.matches()) {
|
|
|
|
return m.group(1);
|
2014-05-17 17:52:00 +02:00
|
|
|
}
|
2017-11-11 09:10:08 +01:00
|
|
|
throw new MalformedURLException("Expected modelmayhem URL format: " +
|
|
|
|
"modelmayhem.com/portfolio/ID/viewall - got " + url + " instead");
|
2014-05-17 17:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-11-11 09:10:08 +01:00
|
|
|
public Document getFirstPage() throws IOException {
|
|
|
|
// "url" is an instance field of the superclass
|
|
|
|
return Http.url(url).get();
|
2014-05-17 17:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-11-11 09:10:08 +01:00
|
|
|
public List<String> getURLsFromPage(Document doc) {
|
|
|
|
List<String> result = new ArrayList<>();
|
|
|
|
for (Element el : doc.select("tr.a_pics > td > div > a")) {
|
|
|
|
String image_URL = el.select("img").attr("src").replaceAll("_m", "");
|
|
|
|
if (image_URL.contains("http")) {
|
|
|
|
result.add(image_URL);
|
|
|
|
}
|
2014-05-17 17:52:00 +02:00
|
|
|
}
|
2017-11-11 09:10:08 +01:00
|
|
|
return result;
|
2014-05-17 17:52:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-11 09:10:08 +01:00
|
|
|
@Override
|
|
|
|
public void downloadURL(URL url, int index) {
|
|
|
|
addURLToDownload(url, getPrefix(index));
|
|
|
|
}
|
2014-05-17 17:52:00 +02:00
|
|
|
}
|