From 7587961e90f64ef5184c6f13aa483bb084ebebde Mon Sep 17 00:00:00 2001 From: "Jozsef.Kerekes" Date: Fri, 6 Oct 2017 20:45:22 +0300 Subject: [PATCH 1/3] Instagram: [standard_resolution] is not a JSONObject. --- .../ripme/ripper/rippers/InstagramRipper.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 0be42535..8cac12ba 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java @@ -138,9 +138,15 @@ public class InstagramRipper extends AbstractJSONRipper { private String getMedia(JSONObject data) { String imageURL = ""; if (data.has("videos")) { - imageURL = data.getJSONObject("videos").getJSONObject("standard_resolution").getString("url"); + JSONObject videosObject = data.getJSONObject("videos"); + if (!videosObject.isNull("standard_resolution")) { + imageURL = videosObject.getJSONObject("standard_resolution").getString("url"); + } } else if (data.has("images")) { - imageURL = data.getJSONObject("images").getJSONObject("standard_resolution").getString("url"); + JSONObject imagesObject = data.getJSONObject("images"); + if (!imagesObject.isNull("standard_resolution")) { + imageURL = imagesObject.getJSONObject("standard_resolution").getString("url"); + } } return imageURL; } @@ -158,14 +164,14 @@ public class InstagramRipper extends AbstractJSONRipper { for (int carouselIndex = 0; carouselIndex < carouselMedias.length(); carouselIndex++) { JSONObject carouselMedia = (JSONObject) carouselMedias.get(carouselIndex); String imageURL = getMedia(carouselMedia); - if (!imageURL.equals("")) { + if (!"".equals(imageURL)) { imageURL = getOriginalUrl(imageURL); imageURLs.add(imageURL); } } } else { String imageURL = getMedia(data); - if (!imageURL.equals("")) { + if (!"".equals(imageURL)) { imageURL = getOriginalUrl(imageURL); imageURLs.add(imageURL); } From 0c995f67f0796f56e6bbde33405adcf769942d01 Mon Sep 17 00:00:00 2001 From: "Jozsef.Kerekes" Date: Fri, 6 Oct 2017 21:04:28 +0300 Subject: [PATCH 2/3] Instagram: [standard_resolution] is not a JSONObject. Improvement after feedback --- .../com/rarchives/ripme/ripper/rippers/InstagramRipper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 8cac12ba..e81aa031 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java @@ -137,13 +137,14 @@ public class InstagramRipper extends AbstractJSONRipper { private String getMedia(JSONObject data) { String imageURL = ""; + JSONObject mediaObject; if (data.has("videos")) { - JSONObject videosObject = data.getJSONObject("videos"); + mediaObject = data.getJSONObject("videos"); if (!videosObject.isNull("standard_resolution")) { imageURL = videosObject.getJSONObject("standard_resolution").getString("url"); } } else if (data.has("images")) { - JSONObject imagesObject = data.getJSONObject("images"); + mediaObject = data.getJSONObject("images"); if (!imagesObject.isNull("standard_resolution")) { imageURL = imagesObject.getJSONObject("standard_resolution").getString("url"); } From f8be5f2d749033a8f4e5cc1b6c701194cdc08501 Mon Sep 17 00:00:00 2001 From: metaprime Date: Thu, 12 Oct 2017 02:22:24 -0700 Subject: [PATCH 3/3] Fix style --- .../ripme/ripper/rippers/InstagramRipper.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 e81aa031..b4a3304f 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java @@ -137,17 +137,17 @@ public class InstagramRipper extends AbstractJSONRipper { private String getMedia(JSONObject data) { String imageURL = ""; - JSONObject mediaObject; + JSONObject mediaObject; if (data.has("videos")) { - mediaObject = data.getJSONObject("videos"); - if (!videosObject.isNull("standard_resolution")) { - imageURL = videosObject.getJSONObject("standard_resolution").getString("url"); - } + mediaObject = data.getJSONObject("videos"); + if (!mediaObject.isNull("standard_resolution")) { + imageURL = mediaObject.getJSONObject("standard_resolution").getString("url"); + } } else if (data.has("images")) { - mediaObject = data.getJSONObject("images"); - if (!imagesObject.isNull("standard_resolution")) { - imageURL = imagesObject.getJSONObject("standard_resolution").getString("url"); - } + mediaObject = data.getJSONObject("images"); + if (!mediaObject.isNull("standard_resolution")) { + imageURL = mediaObject.getJSONObject("standard_resolution").getString("url"); + } } return imageURL; } @@ -165,14 +165,14 @@ public class InstagramRipper extends AbstractJSONRipper { for (int carouselIndex = 0; carouselIndex < carouselMedias.length(); carouselIndex++) { JSONObject carouselMedia = (JSONObject) carouselMedias.get(carouselIndex); String imageURL = getMedia(carouselMedia); - if (!"".equals(imageURL)) { + if (!imageURL.equals("")) { imageURL = getOriginalUrl(imageURL); imageURLs.add(imageURL); } } } else { String imageURL = getMedia(data); - if (!"".equals(imageURL)) { + if (!imageURL.equals("")) { imageURL = getOriginalUrl(imageURL); imageURLs.add(imageURL); }