From 8bb9a8d1c01d5373b38e08e753aa005a11534678 Mon Sep 17 00:00:00 2001 From: 4pr0n Date: Tue, 13 Jan 2015 00:27:04 -0800 Subject: [PATCH] Fixing reddit ripper for single posts --- .../ripme/ripper/rippers/RedditRipper.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java index 3a234dac..f7670d79 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java @@ -121,24 +121,27 @@ public class RedditRipper extends AlbumRipper { int attempts = 0; logger.info(" Retrieving " + url); - JSONObject json = null; - while(json == null && attempts++ < 3) { + String jsonString = null; + while(jsonString == null && attempts++ < 3) { try { - json = Http.url(url).getJSON(); + jsonString = Http.url(url) + .ignoreContentType() + .response() + .body(); } catch(SocketTimeoutException ex) { if(attempts >= 3) throw ex; logger.warn(String.format("[!] Connection timed out (attempt %d)", attempts)); } } - Object jsonObj = new JSONTokener(json.toString()).nextValue(); + Object jsonObj = new JSONTokener(jsonString).nextValue(); JSONArray jsonArray = new JSONArray(); if (jsonObj instanceof JSONObject) { jsonArray.put( (JSONObject) jsonObj); } else if (jsonObj instanceof JSONArray){ jsonArray = (JSONArray) jsonObj; } else { - logger.warn("[!] Unable to parse child: " + json.toString()); + logger.warn("[!] Unable to parse JSON: " + jsonString); } return jsonArray; }