diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/TumblrRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/TumblrRipper.java index 58d086b7..93e7b318 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/TumblrRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/TumblrRipper.java @@ -19,6 +19,9 @@ import com.rarchives.ripme.ripper.AlbumRipper; import com.rarchives.ripme.ui.RipStatusMessage.STATUS; import com.rarchives.ripme.utils.Http; import com.rarchives.ripme.utils.Utils; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; public class TumblrRipper extends AlbumRipper { @@ -46,6 +49,10 @@ public class TumblrRipper extends AlbumRipper { * @return Tumblr API key */ public static String getApiKey() { + // Use a different api ket for unit tests so we don't get 429 errors + if (isThisATest()) { + return "UHpRFx16HFIRgQjtjJKgfVIcwIeb71BYwOQXTMtiCvdSEPjV7N"; + } if (API_KEY == null) { API_KEY = pickRandomApiKey(); } @@ -235,7 +242,6 @@ public class TumblrRipper extends AlbumRipper { for (int j = 0; j < photos.length(); j++) { photo = photos.getJSONObject(j); try { - // If the url is shorter than 65 chars long we skip it because it's those images don't support grabbing them in fullsize fileURL = new URL(photo.getJSONObject("original_size").getString("url").replaceAll("http:", "https:")); m = p.matcher(fileURL.toString()); @@ -257,6 +263,16 @@ public class TumblrRipper extends AlbumRipper { LOGGER.error("[!] Error while parsing video in " + post, e); return true; } + } else if (post.has("body")) { + Document d = Jsoup.parse(post.getString("body")); + if (!d.select("img").attr("src").isEmpty()) { + try { + addURLToDownload(new URL(d.select("img").attr("src"))); + } catch (MalformedURLException e) { + LOGGER.error("[!] Error while getting embedded image at " + post, e); + return true; + } + } } if (albumType == ALBUM_TYPE.POST) { return false; diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TumblrRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TumblrRipperTest.java index eb616c4a..2de62e51 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TumblrRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TumblrRipperTest.java @@ -7,19 +7,21 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.TumblrRipper; public class TumblrRipperTest extends RippersTest { - // https://github.com/RipMeApp/ripme/issues/250 - /* - public void testTumblrFullRip() throws IOException { - TumblrRipper ripper = new TumblrRipper(new URL("http://wrouinr.tumblr.com/archive")); + +// public void testTumblrFullRip() throws IOException { +// TumblrRipper ripper = new TumblrRipper(new URL("http://wrouinr.tumblr.com")); +// testRipper(ripper); +// } +// public void testTumblrTagRip() throws IOException { +// TumblrRipper ripper = new TumblrRipper(new URL("https://these-are-my-b-sides.tumblr.com/tagged/boobs")); +// testRipper(ripper); +// } +// public void testTumblrPostRip() throws IOException { +// TumblrRipper ripper = new TumblrRipper(new URL("http://sadbaffoon.tumblr.com/post/132045920789/what-a-hoe")); +// testRipper(ripper); +// } + public void testEmbeddedImage() throws IOException { + TumblrRipper ripper = new TumblrRipper(new URL("https://these-are-my-b-sides.tumblr.com/post/178225921524/this-was-fun")); testRipper(ripper); } - public void testTumblrTagRip() throws IOException { - TumblrRipper ripper = new TumblrRipper(new URL("http://topinstagirls.tumblr.com/tagged/berlinskaya")); - testRipper(ripper); - } - public void testTumblrPostRip() throws IOException { - TumblrRipper ripper = new TumblrRipper(new URL("http://sadbaffoon.tumblr.com/post/132045920789/what-a-hoe")); - testRipper(ripper); - } - */ }