From bd70b6f4dd577931eb4e9d3fb1695bedf1907c93 Mon Sep 17 00:00:00 2001 From: 4pr0n Date: Tue, 22 Dec 2015 21:10:30 -0800 Subject: [PATCH] v1.2.7: Fix 500px to fetch NSFW images. Closes #278 --- pom.xml | 2 +- .../ripme/ripper/rippers/FivehundredpxRipper.java | 13 +++++++++---- .../java/com/rarchives/ripme/ui/UpdateUtils.java | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 2a2f7eba..3870b89e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.2.6 + 1.2.7 ripme http://rip.rarchives.com diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/FivehundredpxRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/FivehundredpxRipper.java index 3da540cb..91e1c51b 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/FivehundredpxRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/FivehundredpxRipper.java @@ -185,24 +185,29 @@ public class FivehundredpxRipper extends AbstractJSONRipper { List imageURLs = new ArrayList(); JSONArray photos = json.getJSONArray("photos"); for (int i = 0; i < photos.length(); i++) { + if (super.isStopped()) { + break; + } JSONObject photo = photos.getJSONObject(i); String imageURL = null; String rawUrl = "https://500px.com" + photo.getString("url"); Document doc; - Elements metas = new Elements(); + Elements images = new Elements(); try { logger.debug("Loading " + rawUrl); super.retrievingSource(rawUrl); doc = Http.url(rawUrl).get(); - metas = doc.select("meta[property=\"twitter:image:src\"]"); + images = doc.select("div#preload img"); } catch (IOException e) { logger.error("Error fetching full-size image from " + rawUrl, e); } - if (metas.size() > 0) { - imageURL = metas.first().attr("content"); + if (images.size() > 0) { + imageURL = images.first().attr("src"); + logger.debug("Found full-size non-watermarked image: " + imageURL); } else { + logger.debug("Falling back to image_url from API response"); imageURL = photo.getString("image_url"); imageURL = imageURL.replaceAll("/4\\.", "/5."); // See if there's larger images diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index ddc6dcec..1bc5ce28 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils; public class UpdateUtils { private static final Logger logger = Logger.getLogger(UpdateUtils.class); - private static final String DEFAULT_VERSION = "1.2.6"; + private static final String DEFAULT_VERSION = "1.2.7"; private static final String updateJsonURL = "http://rarchives.com/ripme.json"; private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String mainFileName = "ripme.jar";