Added Fapproved support. #8
This commit is contained in:
parent
0ff9fa667b
commit
b5e10c0149
@ -0,0 +1,90 @@
|
|||||||
|
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.Jsoup;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ripper.AlbumRipper;
|
||||||
|
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
||||||
|
|
||||||
|
public class FapprovedRipper extends AlbumRipper {
|
||||||
|
|
||||||
|
private static final String DOMAIN = "fapproved.com",
|
||||||
|
HOST = "fapproved";
|
||||||
|
private static final Logger logger = Logger.getLogger(FapprovedRipper.class);
|
||||||
|
|
||||||
|
public FapprovedRipper(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 {
|
||||||
|
Pattern p = Pattern.compile("^https?://fapproved\\.com/users/([a-zA-Z0-9\\-_]{1,}).*$");
|
||||||
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
|
if (m.matches()) {
|
||||||
|
return new URL("http://fapproved.com/users/" + m.group(1));
|
||||||
|
}
|
||||||
|
throw new MalformedURLException("Expected username in URL (fapproved.com/users/username and not " + url);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void rip() throws IOException {
|
||||||
|
int page = 0;
|
||||||
|
String url, user = getGID(this.url);
|
||||||
|
boolean hasNextPage = true;
|
||||||
|
while (hasNextPage) {
|
||||||
|
page++;
|
||||||
|
url = "http://fapproved.com/users/" + user + "/images?page=" + page;
|
||||||
|
this.sendUpdate(STATUS.LOADING_RESOURCE, url);
|
||||||
|
logger.info(" Retrieving " + url);
|
||||||
|
Document doc = Jsoup.connect(url)
|
||||||
|
.ignoreContentType(true)
|
||||||
|
.get();
|
||||||
|
for (Element image : doc.select("div.actual-image img")) {
|
||||||
|
String imageUrl = image.attr("src");
|
||||||
|
if (imageUrl.startsWith("//")) {
|
||||||
|
imageUrl = "http:" + imageUrl;
|
||||||
|
}
|
||||||
|
addURLToDownload(new URL(imageUrl));
|
||||||
|
}
|
||||||
|
if ( (doc.select("div.pagination li.next.disabled").size() != 0)
|
||||||
|
|| (doc.select("div.pagination").size() == 0) ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.error("[!] Interrupted while waiting to load next album:", e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
waitForThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHost() {
|
||||||
|
return HOST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGID(URL url) throws MalformedURLException {
|
||||||
|
Pattern p = Pattern.compile("^https?://[w.]*fapproved.com/users/([a-zA-Z0-9\\-_]{3,}).*$");
|
||||||
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
|
if (m.matches()) {
|
||||||
|
return m.group(1);
|
||||||
|
}
|
||||||
|
throw new MalformedURLException("Fapproved user not found in " + url + ", expected http://fapproved.com/users/username/images");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -81,7 +81,6 @@ public class InstagramRipper extends AlbumRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rip() throws IOException {
|
public void rip() throws IOException {
|
||||||
int index = 0;
|
|
||||||
String userID = getUserID(this.url);
|
String userID = getUserID(this.url);
|
||||||
String baseURL = "http://statigr.am/controller_nl.php?action=getPhotoUserPublic&user_id=" + userID;
|
String baseURL = "http://statigr.am/controller_nl.php?action=getPhotoUserPublic&user_id=" + userID;
|
||||||
String params = "";
|
String params = "";
|
||||||
@ -104,16 +103,15 @@ public class InstagramRipper extends AlbumRipper {
|
|||||||
if (data.has("id")) {
|
if (data.has("id")) {
|
||||||
nextMaxID = data.getString("id");
|
nextMaxID = data.getString("id");
|
||||||
}
|
}
|
||||||
|
String imageUrl;
|
||||||
if (data.has("videos")) {
|
if (data.has("videos")) {
|
||||||
index += 1;
|
imageUrl = data.getJSONObject("videos").getJSONObject("standard_resolution").getString("url");
|
||||||
String video = data.getJSONObject("videos").getJSONObject("standard_resolution").getString("url");
|
|
||||||
addURLToDownload(new URL(video), String.format("%03d_", index));
|
|
||||||
} else if (data.has("images")) {
|
} else if (data.has("images")) {
|
||||||
index += 1;
|
imageUrl = data.getJSONObject("images").getJSONObject("standard_resolution").getString("url");
|
||||||
String image = data.getJSONObject("images").getJSONObject("standard_resolution").getString("url");
|
} else {
|
||||||
// addURLToDownload(new URL(image), String.format("%03d_", index));
|
continue;
|
||||||
addURLToDownload(new URL(image));
|
|
||||||
}
|
}
|
||||||
|
addURLToDownload(new URL(imageUrl));
|
||||||
}
|
}
|
||||||
JSONObject pagination = json.getJSONObject("pagination");
|
JSONObject pagination = json.getJSONObject("pagination");
|
||||||
if (nextMaxID.equals("")) {
|
if (nextMaxID.equals("")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user