FuraffinityRipper can now rip non-public albums

This commit is contained in:
cyian-1756 2017-12-24 08:39:27 -05:00
parent e3f88a4f5c
commit dfeb0c3616

View File

@ -28,8 +28,12 @@ import com.rarchives.ripme.utils.Http;
public class FuraffinityRipper extends AbstractHTMLRipper { public class FuraffinityRipper extends AbstractHTMLRipper {
private static Map<String, String> cookies=null;
private static final String urlBase = "https://www.furaffinity.net"; private static final String urlBase = "https://www.furaffinity.net";
private static Map<String,String> cookies = new HashMap<>();
static {
cookies.put("b", "bd5ccac8-51dc-4265-8ae1-7eac685ad667");
cookies.put("a", "7c41b782-d01d-4b0e-b45b-62a4f0b2a369");
}
// Thread pool for finding direct image links from "image" pages (html) // Thread pool for finding direct image links from "image" pages (html)
private DownloadThreadPool furaffinityThreadPool private DownloadThreadPool furaffinityThreadPool
@ -59,57 +63,28 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
} }
@Override @Override
public Document getFirstPage() throws IOException { public Document getFirstPage() throws IOException {
return Http.url(url).cookies(cookies).get();
return Http.url(url).get();
}
private void login() throws IOException {
String user = new String(Base64.decode("cmlwbWU="));
String pass = new String(Base64.decode("cmlwbWVwYXNzd29yZA=="));
Response loginPage = Http.url(urlBase + "/login/")
.referrer(urlBase)
.response();
cookies = loginPage.cookies();
Map<String,String> formData = new HashMap<>();
formData.put("action", "login");
formData.put("retard_protection", "1");
formData.put("name", user);
formData.put("pass", pass);
formData.put("login", "Login to FurAffinity");
Response doLogin = Http.url(urlBase + "/login/?ref=" + url)
.referrer(urlBase + "/login/")
.data(formData)
.method(Method.POST)
.response();
cookies.putAll(doLogin.cookies());
} }
@Override @Override
public Document getNextPage(Document doc) throws IOException { public Document getNextPage(Document doc) throws IOException {
// Find next page // Find next page
Elements nextPageUrl = doc.select("td[align=right] form"); Elements nextPageUrl = doc.select("a.right");
if (nextPageUrl.size() == 0) { if (nextPageUrl.size() == 0) {
throw new IOException("No more pages"); throw new IOException("No more pages");
} }
String nextUrl = urlBase + nextPageUrl.first().attr("action"); String nextUrl = urlBase + nextPageUrl.first().attr("href");
sleep(500); sleep(500);
Document nextPage = Http.url(nextUrl).get(); Document nextPage = Http.url(nextUrl).cookies(cookies).get();
Elements hrefs = nextPage.select("div#no-images");
if (hrefs.size() != 0) {
throw new IOException("No more pages");
}
return nextPage; return nextPage;
} }
private String getImageFromPost(String url) { private String getImageFromPost(String url) {
try { try {
logger.info("found url " + Http.url(url).get().select("meta[property=og:image]").attr("content")); logger.info("found url " + Http.url(url).cookies(cookies).get().select("meta[property=og:image]").attr("content"));
return Http.url(url).get().select("meta[property=og:image]").attr("content"); return Http.url(url).cookies(cookies).get().select("meta[property=og:image]").attr("content");
} catch (IOException e) { } catch (IOException e) {
return ""; return "";
} }