From 7587961e90f64ef5184c6f13aa483bb084ebebde Mon Sep 17 00:00:00 2001 From: "Jozsef.Kerekes" Date: Fri, 6 Oct 2017 20:45:22 +0300 Subject: [PATCH] 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); }