diff --git a/pom.xml b/pom.xml
index 4e5b550f..41d404bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.rarchives.ripme
ripme
jar
- 1.2.11
+ 1.2.12
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 91e1c51b..1c57cf82 100644
--- a/src/main/java/com/rarchives/ripme/ripper/rippers/FivehundredpxRipper.java
+++ b/src/main/java/com/rarchives/ripme/ripper/rippers/FivehundredpxRipper.java
@@ -98,6 +98,40 @@ public class FivehundredpxRipper extends AbstractJSONRipper {
return username + "_faves";
}
+ // http://500px.com/tsyganov/galleries
+ p = Pattern.compile("^.*500px.com/([a-zA-Z0-9\\-_]+)/galleries/?$");
+ m = p.matcher(url.toExternalForm());
+ if (m.matches()) {
+ String username = m.group(1);
+ String userID;
+ try {
+ userID = getUserID(username);
+ } catch (IOException e) {
+ throw new MalformedURLException("Unable to get User ID from username (" + username + ")");
+ }
+ baseURL += "/users/" + userID + "/galleries"
+ + "?rpp=100";
+ return username + "_galleries";
+ }
+
+ // https://500px.com/getesmart86/galleries/olga
+ p = Pattern.compile("^.*500px.com/([a-zA-Z0-9\\-_]+)/galleries/([a-zA-Z0-9\\-_]+)/?$");
+ m = p.matcher(url.toExternalForm());
+ if (m.matches()) {
+ String username = m.group(1);
+ String subgallery = m.group(2);
+ String userID;
+ try {
+ userID = getUserID(username);
+ } catch (IOException e) {
+ throw new MalformedURLException("Unable to get User ID from username (" + username + ")");
+ }
+ baseURL += "/users/" + userID + "/galleries/" + subgallery + "/items"
+ + "?rpp=100"
+ + "&image_size=5";
+ return username + "_galleries_" + subgallery;
+ }
+
// http://500px.com/tsyganov (photos)
p = Pattern.compile("^.*500px.com/([a-zA-Z0-9\\-_]+)/?$");
m = p.matcher(url.toExternalForm());
@@ -117,12 +151,52 @@ public class FivehundredpxRipper extends AbstractJSONRipper {
+ " Got: " + url);
}
+ /** Convert username to UserID. */
+ private String getUserID(String username) throws IOException {
+ logger.info("Fetching user ID for " + username);
+ JSONObject json = new Http("https://api.500px.com/v1/" +
+ "users/show" +
+ "?username=" + username +
+ "&consumer_key=" + CONSUMER_KEY)
+ .getJSON();
+ return Long.toString(json.getJSONObject("user").getLong("id"));
+ }
+
@Override
public JSONObject getFirstPage() throws IOException {
URL apiURL = new URL(baseURL + "&consumer_key=" + CONSUMER_KEY);
logger.debug("apiURL: " + apiURL);
JSONObject json = Http.url(apiURL).getJSON();
- if (baseURL.contains("/blogs?")) {
+
+ if (baseURL.contains("/galleries?")) {
+ // We're in the root /galleries folder, need to get all images from all galleries.
+ JSONObject result = new JSONObject();
+ result.put("photos", new JSONArray());
+ // Iterate over every gallery
+ JSONArray jsonGalleries = json.getJSONArray("galleries");
+ for (int i = 0; i < jsonGalleries.length(); i++) {
+ if (i > 0) {
+ sleep(500);
+ }
+ JSONObject jsonGallery = jsonGalleries.getJSONObject(i);
+ long galleryID = jsonGallery.getLong("id");
+ String userID = Long.toString(jsonGallery.getLong("user_id"));
+ String blogURL = "https://api.500px.com/v1/users/" + userID + "/galleries/" + galleryID + "/items"
+ + "?rpp=100"
+ + "&image_size=5"
+ + "&consumer_key=" + CONSUMER_KEY;
+ logger.info("Loading " + blogURL);
+ sendUpdate(STATUS.LOADING_RESOURCE, "Gallery ID " + galleryID + " for userID " + userID);
+ JSONObject thisJSON = Http.url(blogURL).getJSON();
+ JSONArray thisPhotos = thisJSON.getJSONArray("photos");
+ // Iterate over every image in this story
+ for (int j = 0; j < thisPhotos.length(); j++) {
+ result.getJSONArray("photos").put(thisPhotos.getJSONObject(j));
+ }
+ }
+ return result;
+ }
+ else if (baseURL.contains("/blogs?")) {
// List of stories to return
JSONObject result = new JSONObject();
result.put("photos", new JSONArray());
diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java
index 01bb99cd..9d417b3a 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.11";
+ private static final String DEFAULT_VERSION = "1.2.12";
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";