Skip to content

Commit

Permalink
1.0.75 - 500px gets higher-res images #8
Browse files Browse the repository at this point in the history
  • Loading branch information
4pr0n committed Jun 28, 2014
1 parent c7fce6a commit baab27d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.rarchives.ripme</groupId>
<artifactId>ripme</artifactId>
<packaging>jar</packaging>
<version>1.0.74</version>
<version>1.0.75</version>
<name>ripme</name>
<url>http://rip.rarchives.com</url>
<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.rarchives.ripme.ripper.rippers;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
Expand Down Expand Up @@ -64,6 +65,7 @@ public String getGID(URL url) throws MalformedURLException {
baseURL += "/blogs/" + blogid
+ "?feature=user"
+ "&username=" + username
+ "&image_size=5"
+ "&rpp=100";
return username + "_stories_" + blogid;
}
Expand All @@ -89,7 +91,7 @@ public String getGID(URL url) throws MalformedURLException {
+ "?feature=user_favorites"
+ "&username=" + username
+ "&rpp=100"
+ "&image_size=4";
+ "&image_size=5";
return username + "_faves";
}

Expand All @@ -102,8 +104,8 @@ public String getGID(URL url) throws MalformedURLException {
+ "?feature=user"
+ "&username=" + username
+ "&rpp=100"
+ "&image_size=4";
return username + "_faves";
+ "&image_size=5";
return username;
}

throw new MalformedURLException(
Expand Down Expand Up @@ -133,6 +135,7 @@ public JSONObject getFirstPage() throws IOException {
+ "?feature=user"
+ "&username=" + username
+ "&rpp=100"
+ "&image_size=5"
+ "&consumer_key=" + CONSUMER_KEY;
logger.info("Loading " + blogURL);
sendUpdate(STATUS.LOADING_RESOURCE, "Story ID " + blogid + " for user " + username);
Expand Down Expand Up @@ -174,10 +177,36 @@ public List<String> getURLsFromJSON(JSONObject json) {
List<String> imageURLs = new ArrayList<String>();
JSONArray photos = json.getJSONArray("photos");
for (int i = 0; i < photos.length(); i++) {
imageURLs.add(photos.getJSONObject(i).getString("image_url"));
JSONObject photo = photos.getJSONObject(i);
String imageURL = photo.getString("image_url");
imageURL = imageURL.replaceAll("/4\\.", "/5.");
// See if there's larger images
for (String imageSize : new String[] { "2048" } ) {
String fsURL = imageURL.replaceAll("/5\\.", "/" + imageSize + ".");
sleep(10);
if (urlExists(fsURL)) {
logger.info("Found larger image at " + fsURL);
imageURL = fsURL;
break;
}
}
imageURLs.add(imageURL);
}
return imageURLs;
}

private boolean urlExists(String url) {
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("HEAD");
if (connection.getResponseCode() != 200) {
throw new IOException("Couldn't find full-size image at " + url);
}
return true;
} catch (IOException e) {
return false;
}
}

@Override
public void downloadURL(URL url, int index) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rarchives/ripme/ui/UpdateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class UpdateUtils {

private static final Logger logger = Logger.getLogger(UpdateUtils.class);
private static final String DEFAULT_VERSION = "1.0.74";
private static final String DEFAULT_VERSION = "1.0.75";
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";
Expand Down

0 comments on commit baab27d

Please sign in to comment.