From 75908f4b0fe7fc3c99aa2106cb76bce3cfea1681 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 16 Aug 2018 09:50:01 -0400 Subject: [PATCH 1/3] Ripme no longer downloads whole files during unittests if the file is over 10mb --- .../java/com/rarchives/ripme/ripper/AbstractRipper.java | 4 ++-- .../com/rarchives/ripme/ripper/DownloadFileThread.java | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java index eeaf8fd1..e210e183 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java @@ -47,7 +47,7 @@ public abstract class AbstractRipper // Everytime addUrlToDownload skips a already downloaded url this increases by 1 public int alreadyDownloadedUrls = 0; private boolean shouldStop = false; - private boolean thisIsATest = false; + private static boolean thisIsATest = false; public void stop() { shouldStop = true; @@ -611,7 +611,7 @@ public abstract class AbstractRipper LOGGER.debug("THIS IS A TEST RIP"); thisIsATest = true; } - protected boolean isThisATest() { + protected static boolean isThisATest() { return thisIsATest; } diff --git a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java index f481919a..ae28ee6e 100644 --- a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java +++ b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java @@ -23,6 +23,7 @@ import org.jsoup.HttpStatusException; import com.rarchives.ripme.ui.RipStatusMessage.STATUS; import com.rarchives.ripme.utils.Utils; +import com.rarchives.ripme.ripper.AbstractRipper; /** * Thread for downloading files. @@ -222,6 +223,14 @@ class DownloadFileThread extends Thread { observer.setBytesCompleted(bytesDownloaded); observer.sendUpdate(STATUS.COMPLETED_BYTES, bytesDownloaded); } + // If this is a test and we're downloading a large file + if (AbstractRipper.isThisATest() && bytesTotal / 10000000 >= 10) { + logger.debug("Not downloading whole file because it is over 10mb and this is a test"); + bis.close(); + fos.close(); + break; + + } } bis.close(); fos.close(); From e192243012048617feda9f38caa635c214495b73 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 16 Aug 2018 09:50:20 -0400 Subject: [PATCH 2/3] Added unittest for hqporner --- .../tst/ripper/rippers/HqpornerRipperTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java new file mode 100644 index 00000000..cdd28797 --- /dev/null +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java @@ -0,0 +1,15 @@ +package com.rarchives.ripme.tst.ripper.rippers; + +import com.rarchives.ripme.ripper.rippers.HqpornerRipper; + +import java.io.IOException; +import java.net.URL; + +public class HqpornerRipperTest extends RippersTest{ + + public void testRip() throws IOException { + HqpornerRipper ripper = new HqpornerRipper(new URL("https://hqporner.com/hdporn/84636-pool_lesson_with_a_cheating_husband.html")); + testRipper(ripper); + } + +} \ No newline at end of file From 93386c16d206eedc988735f53954d6e170204f03 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 16 Aug 2018 13:55:00 -0400 Subject: [PATCH 3/3] Expanded hqporner unit tests --- .../ripme/tst/ripper/rippers/HqpornerRipperTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java index cdd28797..cf87e671 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java @@ -12,4 +12,10 @@ public class HqpornerRipperTest extends RippersTest{ testRipper(ripper); } + public void testGetGID() throws IOException { + URL poolURL = new URL("https://hqporner.com/hdporn/84636-pool_lesson_with_a_cheating_husband.html"); + HqpornerRipper ripper = new HqpornerRipper(poolURL); + assertEquals("84636-pool_lesson_with_a_cheating_husband", ripper.getGID(poolURL)); + } + } \ No newline at end of file