Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,12 @@ public String getHost() {
}
@Override
public boolean hasDescriptionSupport() {
return true;
return false;
}
@Override
public Document getFirstPage() throws IOException {
if (cookies == null || cookies.size() == 0) {
login();
}

return Http.url(url).cookies(cookies).get();
return Http.url(url).get();
}

private void login() throws IOException {
Expand All @@ -84,7 +81,6 @@ private void login() throws IOException {

Response doLogin = Http.url(urlBase + "/login/?ref=" + url)
.referrer(urlBase + "/login/")
.cookies(cookies)
.data(formData)
.method(Method.POST)
.response();
Expand All @@ -101,7 +97,7 @@ public Document getNextPage(Document doc) throws IOException {
String nextUrl = urlBase + nextPageUrl.first().attr("action");

sleep(500);
Document nextPage = Http.url(nextUrl).cookies(cookies).get();
Document nextPage = Http.url(nextUrl).get();

Elements hrefs = nextPage.select("div#no-images");
if (hrefs.size() != 0) {
Expand All @@ -110,12 +106,21 @@ public Document getNextPage(Document doc) throws IOException {
return nextPage;
}

private String getImageFromPost(String url) {
try {
logger.info("found url " + Http.url(url).get().select("meta[property=og:image]").attr("content"));
return Http.url(url).get().select("meta[property=og:image]").attr("content");
} catch (IOException e) {
return "";
}
}

@Override
public List<String> getURLsFromPage(Document page) {
List<String> urls = new ArrayList<>();
Elements urlElements = page.select("figure.t-image > b > u > a");
for (Element e : urlElements) {
urls.add(urlBase + e.select("a").first().attr("href"));
urls.add(getImageFromPost(urlBase + e.select("a").first().attr("href")));
}
return urls;
}
Expand All @@ -138,7 +143,6 @@ public String getDescription(String page) {
// Fetch the image page
Response resp = Http.url(page)
.referrer(this.url)
.cookies(cookies)
.response();
cookies.putAll(resp.cookies());

Expand Down Expand Up @@ -210,8 +214,7 @@ public boolean saveText(URL url, String subdirectory, String text, int index) {
}
@Override
public void downloadURL(URL url, int index) {
furaffinityThreadPool.addThread(new FuraffinityDocumentThread(url));
sleep(250);
addURLToDownload(url, getPrefix(index));
}

@Override
Expand All @@ -222,6 +225,7 @@ public String getGID(URL url) throws MalformedURLException {
if (m.matches()) {
return m.group(1);
}

throw new MalformedURLException("Expected furaffinity.net URL format: "
+ "www.furaffinity.net/gallery/username - got " + url
+ " instead");
Expand All @@ -235,37 +239,8 @@ private class FuraffinityDocumentThread extends Thread {
this.url = url;
}

@Override
public void run() {
try {
Document doc = Http.url(url).cookies(cookies).get();
// Find image
Elements donwloadLink = doc.select("div.alt1 b a[href^=//d.facdn.net/]");
if (donwloadLink.size() == 0) {
logger.warn("Could not download " + this.url);
return;
}
String link = "http:" + donwloadLink.first().attr("href");
logger.info("Found URL " + link);
String[] fileNameSplit = link.split("/");
String fileName = fileNameSplit[fileNameSplit.length -1];
fileName = fileName.replaceAll("[0-9]*\\.", "");
String[] fileExtSplit = link.split("\\.");
String fileExt = fileExtSplit[fileExtSplit.length -1];
fileName = fileName.replaceAll(fileExt, "");
File saveAS;
fileName = fileName.replace("[0-9]*\\.", "");
saveAS = new File(
workingDir.getCanonicalPath()
+ File.separator
+ fileName
+ "."
+ fileExt);
addURLToDownload(new URL(link),saveAS,"",cookies);
} catch (IOException e) {
logger.error("[!] Exception while loading/parsing " + this.url, e);
}
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
import com.rarchives.ripme.ripper.rippers.FuraffinityRipper;

public class FuraffinityRipperTest extends RippersTest {
// https://github.com/RipMeApp/ripme/issues/183
/*
public void testFuraffinityAlbum() throws IOException {
FuraffinityRipper ripper = new FuraffinityRipper(new URL("https://www.furaffinity.net/gallery/mustardgas/"));
testRipper(ripper);
}
*/
}