From 00f1b8a5e9c0fafbc38f495dffc831afe20306d6 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Mon, 11 Jun 2018 08:31:47 -0400 Subject: [PATCH] FurAffinityRipper now downloads fullsized images and NSFW images --- .../ripper/rippers/FuraffinityRipper.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/FuraffinityRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/FuraffinityRipper.java index eecde5dd..7dd5b731 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/FuraffinityRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/FuraffinityRipper.java @@ -15,6 +15,7 @@ import java.util.regex.Pattern; import com.rarchives.ripme.ui.RipStatusMessage; import com.rarchives.ripme.utils.Utils; import org.jsoup.Connection.Response; +import org.jsoup.HttpStatusException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -77,6 +78,7 @@ public class FuraffinityRipper extends AbstractHTMLRipper { @Override public Document getFirstPage() throws IOException { setCookies(); + LOGGER.info(Http.url(url).cookies(cookies).get().html()); return Http.url(url).cookies(cookies).get(); } @@ -96,22 +98,33 @@ public class FuraffinityRipper extends AbstractHTMLRipper { } private String getImageFromPost(String url) { + sleep(1000); + Document d = null; try { - LOGGER.info("found url " + Http.url(url).cookies(cookies).get().select("meta[property=og:image]").attr("content")); - return Http.url(url).cookies(cookies).get().select("meta[property=og:image]").attr("content"); + d = Http.url(url).cookies(cookies).get(); + Elements links = d.getElementsByTag("a"); + for (Element link : links) { + if (link.text().equals("Download")) { + LOGGER.info("Found image " + link.attr("href")); + return "https:" + link.attr("href"); + } + } } catch (IOException e) { - return ""; + return null; } + return null; } @Override public List getURLsFromPage(Document page) { List urls = new ArrayList<>(); - Elements urlElements = page.select("figure > b > u > a"); + Elements urlElements = page.select("figure.t-image > b > u > a"); for (Element e : urlElements) { String urlToAdd = getImageFromPost(urlBase + e.select("a").first().attr("href")); - if (urlToAdd.startsWith("http") && urlToAdd.contains("/view/")) { - urls.add(urlToAdd); + if (url != null) { + if (urlToAdd.startsWith("http")) { + urls.add(urlToAdd); + } } } return urls;