Merge pull request #377 from kevin51jiang/GfycatFixAndTest
Gfycat fix and test
This commit is contained in:
commit
ae7ea5f8e6
@ -32,6 +32,8 @@ public class GfycatRipper extends VideoRipper {
|
||||
|
||||
@Override
|
||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||
url = new URL(url.toExternalForm().replace("/gifs/detail", ""));
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
@ -64,6 +66,10 @@ public class GfycatRipper extends VideoRipper {
|
||||
*/
|
||||
public static String getVideoURL(URL url) throws IOException {
|
||||
logger.info("Retrieving " + url.toExternalForm());
|
||||
|
||||
//Sanitize the URL first
|
||||
url = new URL(url.toExternalForm().replace("/gifs/detail", ""));
|
||||
|
||||
Document doc = Http.url(url).get();
|
||||
Elements videos = doc.select("source#mp4Source");
|
||||
if (videos.size() == 0) {
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.rarchives.ripme.tst.ripper.rippers;
|
||||
|
||||
import com.rarchives.ripme.ripper.rippers.video.GfycatRipper;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
public class GfycatRipperTest extends RippersTest {
|
||||
|
||||
/**
|
||||
* Rips correctly formatted URL directly from Gfycat
|
||||
* @throws IOException
|
||||
*/
|
||||
public void GfycatGoodURL() throws IOException{
|
||||
GfycatRipper ripper = new GfycatRipper(new URL("https://gfycat.com/TemptingExcellentIchthyosaurs"));
|
||||
testRipper(ripper);
|
||||
}
|
||||
/**
|
||||
* Rips badly formatted URL directly from Gfycat
|
||||
* @throws IOException
|
||||
*/
|
||||
public void GfycatBadURL() throws IOException {
|
||||
GfycatRipper ripper = new GfycatRipper(new URL("https://gfycat.com/gifs/detail/limitedtestyamericancrow"));
|
||||
testRipper(ripper);
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.rarchives.ripme.ripper.rippers.RedditRipper;
|
||||
import com.rarchives.ripme.ripper.rippers.video.GfycatRipper;
|
||||
|
||||
public class RedditRipperTest extends RippersTest {
|
||||
// https://github.com/RipMeApp/ripme/issues/253 - Disabled tests: RedditRipperTest#testRedditSubreddit*Rip is flaky
|
||||
@ -22,4 +23,25 @@ public class RedditRipperTest extends RippersTest {
|
||||
RedditRipper ripper = new RedditRipper(new URL("http://www.reddit.com/r/UnrealGirls/comments/1ziuhl/in_class_veronique_popa/"));
|
||||
testRipper(ripper);
|
||||
}
|
||||
|
||||
/**
|
||||
* GFYCAT TEST
|
||||
* Tests a good GfycatURL (no "/gifs/detail")
|
||||
* @throws IOException
|
||||
*/
|
||||
public void testRedditGfyGoodURL() throws IOException {
|
||||
RedditRipper ripper = new RedditRipper(new URL("https://www.reddit.com/r/bottesting/comments/7msozf/good_link/"));
|
||||
testRipper(ripper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GFYCAT TEST
|
||||
* Tests a Bad URL with the "/gifs/detail" inside.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void testRedditGfyBadURL() throws IOException {
|
||||
RedditRipper ripper = new RedditRipper(new URL("https://www.reddit.com/r/bottesting/comments/7msmhi/bad_link/"));
|
||||
testRipper(ripper);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user