2014-06-12 11:38:31 +02:00
|
|
|
package com.rarchives.ripme.ripper.rippers;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
2014-06-23 04:12:29 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2014-06-12 11:38:31 +02:00
|
|
|
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;
|
|
|
|
|
2014-06-23 04:17:40 +02:00
|
|
|
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
2014-06-22 02:08:42 +02:00
|
|
|
import com.rarchives.ripme.utils.Http;
|
2014-06-12 11:38:31 +02:00
|
|
|
|
2014-06-23 04:17:40 +02:00
|
|
|
public class GirlsOfDesireRipper extends AbstractHTMLRipper {
|
2014-06-12 11:38:31 +02:00
|
|
|
// Current HTML document
|
|
|
|
private Document albumDoc = null;
|
|
|
|
|
|
|
|
public GirlsOfDesireRipper(URL url) throws IOException {
|
|
|
|
super(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getHost() {
|
2014-06-23 04:12:29 +02:00
|
|
|
return "GirlsOfDesire";
|
2014-06-12 11:38:31 +02:00
|
|
|
}
|
2014-06-23 04:12:29 +02:00
|
|
|
@Override
|
|
|
|
public String getDomain() {
|
|
|
|
return "girlsofdesire.org";
|
2014-06-12 11:38:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getAlbumTitle(URL url) throws MalformedURLException {
|
|
|
|
try {
|
|
|
|
// Attempt to use album title as GID
|
2014-06-23 04:12:29 +02:00
|
|
|
Document doc = getFirstPage();
|
|
|
|
Elements elems = doc.select(".albumName");
|
|
|
|
return getHost() + "_" + elems.first().text();
|
2014-06-12 11:38:31 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
// Fall back to default album naming convention
|
|
|
|
logger.warn("Failed to get album title from " + url, e);
|
|
|
|
}
|
|
|
|
return super.getAlbumTitle(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getGID(URL url) throws MalformedURLException {
|
|
|
|
Pattern p;
|
|
|
|
Matcher m;
|
|
|
|
|
|
|
|
p = Pattern.compile("^www\\.girlsofdesire\\.org\\/galleries\\/([\\w\\d-]+)\\/$");
|
|
|
|
m = p.matcher(url.toExternalForm());
|
|
|
|
if (m.matches()) {
|
|
|
|
return m.group(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new MalformedURLException(
|
|
|
|
"Expected girlsofdesire.org gallery format: "
|
|
|
|
+ "http://www.girlsofdesire.org/galleries/<name>/"
|
|
|
|
+ " Got: " + url);
|
|
|
|
}
|
2014-06-23 04:17:40 +02:00
|
|
|
|
2014-06-23 04:12:29 +02:00
|
|
|
@Override
|
|
|
|
public Document getFirstPage() throws IOException {
|
|
|
|
if (albumDoc == null) {
|
|
|
|
albumDoc = Http.url(url).get();
|
|
|
|
}
|
|
|
|
return albumDoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> getURLsFromPage(Document doc) {
|
|
|
|
List<String> imageURLs = new ArrayList<String>();
|
|
|
|
for (Element thumb : doc.select("td.vtop > a > img")) {
|
|
|
|
String imgSrc = thumb.attr("src");
|
|
|
|
imgSrc = imgSrc.replaceAll("_thumb\\.", ".");
|
|
|
|
if (imgSrc.startsWith("/")) {
|
|
|
|
imgSrc = "http://www.girlsofdesire.org" + imgSrc;
|
|
|
|
}
|
|
|
|
imageURLs.add(imgSrc);
|
|
|
|
}
|
|
|
|
return imageURLs;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void downloadURL(URL url, int index) {
|
2014-06-23 04:17:40 +02:00
|
|
|
// Send referrer when downloading images
|
|
|
|
addURLToDownload(url, getPrefix(index), "", this.url.toExternalForm(), null);
|
2014-06-12 11:38:31 +02:00
|
|
|
}
|
|
|
|
}
|