From da469aea4fb4237468f6a81ca088cc4b2f2bd5eb Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 11 Jan 2018 16:07:57 -0500 Subject: [PATCH] Instagram ripper no longer 403s on certain images --- .../com/rarchives/ripme/ripper/rippers/InstagramRipper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java index ec7825e9..076fcfc6 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java @@ -161,6 +161,8 @@ public class InstagramRipper extends AbstractHTMLRipper { } private String getOriginalUrl(String imageURL) { + // Without this regex most images will return a 403 error + imageURL = imageURL.replaceAll("vp/[a-zA-Z0-9]*/", ""); imageURL = imageURL.replaceAll("scontent.cdninstagram.com/hphotos-", "igcdn-photos-d-a.akamaihd.net/hphotos-ak-"); // TODO replace this with a single regex imageURL = imageURL.replaceAll("p150x150/", ""); @@ -177,6 +179,7 @@ public class InstagramRipper extends AbstractHTMLRipper { imageURL = imageURL.replaceAll("s720x720/", ""); imageURL = imageURL.replaceAll("s1080x1080/", ""); imageURL = imageURL.replaceAll("s2048x2048/", ""); + // Instagram returns cropped images to unauthenticated applications to maintain legacy support. // To retrieve the uncropped image, remove this segment from the URL. @@ -232,7 +235,7 @@ public class InstagramRipper extends AbstractHTMLRipper { if (imageURLs.size() == 0) { // We add this one item to the array because either wise // the ripper will error out because we returned an empty array - imageURLs.add(data.getString("thumbnail_src")); + imageURLs.add(getOriginalUrl(data.getString("thumbnail_src"))); } addURLToDownload(new URL(getOriginalUrl(data.getString("thumbnail_src"))), image_date); } else {