v1.2.7: Fix 500px to fetch NSFW images.

Closes #278
This commit is contained in:
4pr0n 2015-12-22 21:10:30 -08:00
parent d4d6e4f57b
commit bd70b6f4dd
3 changed files with 11 additions and 6 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.rarchives.ripme</groupId> <groupId>com.rarchives.ripme</groupId>
<artifactId>ripme</artifactId> <artifactId>ripme</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.2.6</version> <version>1.2.7</version>
<name>ripme</name> <name>ripme</name>
<url>http://rip.rarchives.com</url> <url>http://rip.rarchives.com</url>
<properties> <properties>

View File

@ -185,24 +185,29 @@ public class FivehundredpxRipper extends AbstractJSONRipper {
List<String> imageURLs = new ArrayList<String>(); List<String> imageURLs = new ArrayList<String>();
JSONArray photos = json.getJSONArray("photos"); JSONArray photos = json.getJSONArray("photos");
for (int i = 0; i < photos.length(); i++) { for (int i = 0; i < photos.length(); i++) {
if (super.isStopped()) {
break;
}
JSONObject photo = photos.getJSONObject(i); JSONObject photo = photos.getJSONObject(i);
String imageURL = null; String imageURL = null;
String rawUrl = "https://500px.com" + photo.getString("url"); String rawUrl = "https://500px.com" + photo.getString("url");
Document doc; Document doc;
Elements metas = new Elements(); Elements images = new Elements();
try { try {
logger.debug("Loading " + rawUrl); logger.debug("Loading " + rawUrl);
super.retrievingSource(rawUrl); super.retrievingSource(rawUrl);
doc = Http.url(rawUrl).get(); doc = Http.url(rawUrl).get();
metas = doc.select("meta[property=\"twitter:image:src\"]"); images = doc.select("div#preload img");
} }
catch (IOException e) { catch (IOException e) {
logger.error("Error fetching full-size image from " + rawUrl, e); logger.error("Error fetching full-size image from " + rawUrl, e);
} }
if (metas.size() > 0) { if (images.size() > 0) {
imageURL = metas.first().attr("content"); imageURL = images.first().attr("src");
logger.debug("Found full-size non-watermarked image: " + imageURL);
} }
else { else {
logger.debug("Falling back to image_url from API response");
imageURL = photo.getString("image_url"); imageURL = photo.getString("image_url");
imageURL = imageURL.replaceAll("/4\\.", "/5."); imageURL = imageURL.replaceAll("/4\\.", "/5.");
// See if there's larger images // See if there's larger images

View File

@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils;
public class UpdateUtils { public class UpdateUtils {
private static final Logger logger = Logger.getLogger(UpdateUtils.class); 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 updateJsonURL = "http://rarchives.com/ripme.json";
private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String updateJarURL = "http://rarchives.com/ripme.jar";
private static final String mainFileName = "ripme.jar"; private static final String mainFileName = "ripme.jar";