From 828255d8bcc059e7f3864ebfe71467387754abf9 Mon Sep 17 00:00:00 2001 From: Pocochub <31044179+Pocochub@users.noreply.github.com> Date: Fri, 6 Sep 2019 10:17:49 +0100 Subject: [PATCH 1/2] Fix #1416 - Fails to download gfycat.com/amp/* Adding a string replace to remove the "/amp" --- .../rarchives/ripme/ripper/rippers/GfycatRipper.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java index 7c49fbba..16205115 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java @@ -49,10 +49,12 @@ public class GfycatRipper extends AbstractHTMLRipper { @Override public URL sanitizeURL(URL url) throws MalformedURLException { - url = new URL(url.toExternalForm().replace("/gifs/detail", "")); - - return url; + String sUrl = url.toExternalForm(); + sUrl = sUrl.replace("/gifs/detail", ""); + sUrl = sUrl.replace("/amp", ""); + return new URL(sUrl); } + public boolean isProfile() { Pattern p = Pattern.compile("^https?://[wm.]*gfycat\\.com/@([a-zA-Z0-9]+).*$"); Matcher m = p.matcher(url.toExternalForm()); @@ -154,4 +156,4 @@ public class GfycatRipper extends AbstractHTMLRipper { } throw new IOException(); } -} \ No newline at end of file +} From 3ac381d6d06d1de10a5eb2dd2ff7b49c5f3062c4 Mon Sep 17 00:00:00 2001 From: Pocochub <31044179+Pocochub@users.noreply.github.com> Date: Fri, 6 Sep 2019 10:30:44 +0100 Subject: [PATCH 2/2] Add unit test for Gfycat Amp links --- .../tst/ripper/rippers/GfycatRipperTest.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GfycatRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GfycatRipperTest.java index 014141b1..019350ad 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GfycatRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GfycatRipperTest.java @@ -27,8 +27,21 @@ public class GfycatRipperTest extends RippersTest { testRipper(ripper); } + /** + * Rips a Gfycat profile + * @throws IOException + */ public void testGfycatProfile() throws IOException { GfycatRipper ripper = new GfycatRipper(new URL("https://gfycat.com/@golbanstorage")); testRipper(ripper); } -} \ No newline at end of file + + /** + * Rips a Gfycat amp link + * @throws IOException + */ + public void testGfycatAmp() throws IOException { + GfycatRipper ripper = new GfycatRipper(new URL("https://gfycat.com/amp/TemptingExcellentIchthyosaurs")); + testRipper(ripper); + } +}