|
| 1 | +package com.rarchives.ripme.tst.ripper.rippers; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | +import java.net.URI; |
| 5 | +import java.net.URISyntaxException; |
| 6 | +import java.net.URL; |
| 7 | + |
| 8 | +import org.jsoup.nodes.Document; |
| 9 | +import org.junit.jupiter.api.Assertions; |
| 10 | +import org.junit.jupiter.api.Tag; |
| 11 | +import org.junit.jupiter.api.Test; |
| 12 | + |
| 13 | +import com.rarchives.ripme.ripper.AbstractRipper; |
| 14 | +import com.rarchives.ripme.ripper.rippers.FapwizRipper; |
| 15 | +import com.rarchives.ripme.utils.Http; |
| 16 | +import com.rarchives.ripme.utils.Utils; |
| 17 | + |
| 18 | +public class FapwizRipperTest extends RippersTest { |
| 19 | + @Test |
| 20 | + @Tag("flaky") // It seems like fetching the document within the test can be flaky. |
| 21 | + public void testGetNextPage_NoNextPage() throws IOException, URISyntaxException { |
| 22 | + URL url = new URI("https://fapwiz.com/alison-esha/").toURL(); |
| 23 | + FapwizRipper ripper = new FapwizRipper(url); |
| 24 | + |
| 25 | + Document firstPage = Http.url(url).userAgent(AbstractRipper.USER_AGENT).retries(1).get(); |
| 26 | + try { |
| 27 | + ripper.getNextPage(firstPage); |
| 28 | + // If we don't throw, we failed the text because there *was* a next |
| 29 | + // page even though there shouldn't be. |
| 30 | + Assertions.fail(); |
| 31 | + } catch (IOException exception) { |
| 32 | + Assertions.assertTrue(true); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + @Tag("flaky") // It seems like fetching the document within the test can be flaky. |
| 38 | + public void testGetNextPage_HasNextPage() throws IOException, URISyntaxException { |
| 39 | + URL url = new URI("https://fapwiz.com/miaipanema/").toURL(); |
| 40 | + FapwizRipper ripper = new FapwizRipper(url); |
| 41 | + |
| 42 | + Document firstPage = Http.url(url).userAgent(AbstractRipper.USER_AGENT).retries(1).get(); |
| 43 | + try { |
| 44 | + Document doc = ripper.getNextPage(firstPage); |
| 45 | + Assertions.assertNotNull(doc); |
| 46 | + } catch (IOException exception) { |
| 47 | + // We should have found a next page but didn't. |
| 48 | + Assertions.fail(); |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + public void testRipPost() throws IOException, URISyntaxException { |
| 54 | + URL url = new URI("https://fapwiz.com/petiteasiantravels/riding-at-9-months-pregnant/").toURL(); |
| 55 | + FapwizRipper ripper = new FapwizRipper(url); |
| 56 | + testRipper(ripper); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + public void testRipPostWithNumbersInUsername1() throws IOException, URISyntaxException { |
| 61 | + URL url = new URI("https://fapwiz.com/desperate_bug_7776/lets-be-friends-that-secretly-fuck-thanks/").toURL(); |
| 62 | + FapwizRipper ripper = new FapwizRipper(url); |
| 63 | + testRipper(ripper); |
| 64 | + } |
| 65 | + |
| 66 | + @Test |
| 67 | + public void testRipPostWithEmojiInShortUrl() throws IOException, URISyntaxException { |
| 68 | + URL url = new URI("https://fapwiz.com/miaipanema/my-grip-needs-a-name-%f0%9f%a4%ad%f0%9f%91%87%f0%9f%8f%bc/") |
| 69 | + .toURL(); |
| 70 | + FapwizRipper ripper = new FapwizRipper(url); |
| 71 | + testRipper(ripper); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + public void testRipPostWithEmojiInLongUrlAtEnd() throws IOException, URISyntaxException { |
| 76 | + URL url = new URI( |
| 77 | + "https://fapwiz.com/bimeat1998/just-imagine-youre-out-with-your-girl-and-your-buddies-and-then-she-makes-this-move-%f0%9f%98%8d/") |
| 78 | + .toURL(); |
| 79 | + FapwizRipper ripper = new FapwizRipper(url); |
| 80 | + testRipper(ripper); |
| 81 | + } |
| 82 | + |
| 83 | + @Test |
| 84 | + public void testRipPostWithEmojiInLongUrlInTheMiddle() throws IOException, URISyntaxException { |
| 85 | + URL url = new URI( |
| 86 | + "https://fapwiz.com/miaipanema/new-pov-couch-sex-with-perfect-cumshot-on-my-ass-%f0%9f%92%a6-you-know-where-to-get-it-%f0%9f%94%97%f0%9f%92%96/") |
| 87 | + .toURL(); |
| 88 | + FapwizRipper ripper = new FapwizRipper(url); |
| 89 | + testRipper(ripper); |
| 90 | + } |
| 91 | + |
| 92 | + // TODO Test rip user |
| 93 | + |
| 94 | + // TODO Test rip category |
| 95 | + |
| 96 | + @Test |
| 97 | + public void testPostGetGID1_Simple() throws IOException, URISyntaxException { |
| 98 | + URL url = new URI("https://fapwiz.com/petiteasiantravels/riding-at-9-months-pregnant/").toURL(); |
| 99 | + FapwizRipper ripper = new FapwizRipper(url); |
| 100 | + Assertions.assertEquals("post_petiteasiantravels_riding-at-9-months-pregnant", ripper.getGID(url)); |
| 101 | + } |
| 102 | + |
| 103 | + // Test Post pages GetGID |
| 104 | + |
| 105 | + @Test |
| 106 | + public void testPostGetGID2_WithEmojiInLongUrlInTheMiddle() throws IOException, URISyntaxException { |
| 107 | + URL url = new URI( |
| 108 | + "https://fapwiz.com/miaipanema/new-pov-couch-sex-with-perfect-cumshot-on-my-ass-%f0%9f%92%a6-you-know-where-to-get-it-%f0%9f%94%97%f0%9f%92%96/") |
| 109 | + .toURL(); |
| 110 | + FapwizRipper ripper = new FapwizRipper(url); |
| 111 | + |
| 112 | + // In this case the filesystem safe version of the GID is |
| 113 | + // "post_miaipanema_new-pov-couch-sex-with-perfect-cumshot-on-my-ass-f09f92a6-you-know-where-to-" |
| 114 | + // but the GID doesn't truncate and doesn't remove non-filesystem-safe |
| 115 | + // characters. |
| 116 | + String gid = ripper.getGID(url); |
| 117 | + Assertions.assertEquals( |
| 118 | + "post_miaipanema_new-pov-couch-sex-with-perfect-cumshot-on-my-ass-%f0%9f%92%a6-you-know-where-to-get-it-%f0%9f%94%97%f0%9f%92%96", |
| 119 | + gid); |
| 120 | + |
| 121 | + // Test directory name on disk (filesystem safe sanitized as the ripper will |
| 122 | + // do). |
| 123 | + String directoryName = Utils.filesystemSafe(ripper.getHost() + "_" + gid); |
| 124 | + Assertions.assertEquals( |
| 125 | + "fapwiz_post_miaipanema_new-pov-couch-sex-with-perfect-cumshot-on-my-ass-f09f92a6-you-know-where-to-", |
| 126 | + directoryName); |
| 127 | + } |
| 128 | + |
| 129 | + // Test User pages GetGID |
| 130 | + |
| 131 | + @Test |
| 132 | + public void testUserGetGID1_Simple() throws IOException, URISyntaxException { |
| 133 | + // Test a "simple" username that is all letters. |
| 134 | + URL url = new URI("https://fapwiz.com/petiteasiantravels/").toURL(); |
| 135 | + FapwizRipper ripper = new FapwizRipper(url); |
| 136 | + Assertions.assertEquals("user_petiteasiantravels", ripper.getGID(url)); |
| 137 | + } |
| 138 | + |
| 139 | + @Test |
| 140 | + public void testUserGetGID2_Numbers() throws IOException, URISyntaxException { |
| 141 | + // Test a more complex username that contains numbers. |
| 142 | + URL url = new URI("https://fapwiz.com/bimeat1998/").toURL(); |
| 143 | + FapwizRipper ripper = new FapwizRipper(url); |
| 144 | + Assertions.assertEquals("user_bimeat1998", ripper.getGID(url)); |
| 145 | + } |
| 146 | + |
| 147 | + @Test |
| 148 | + public void testUserGetGID3_HyphensAndNumbers() throws IOException, URISyntaxException { |
| 149 | + // Test a more complex username that contains hyphens and numbers. |
| 150 | + URL url = new URI("https://fapwiz.com/used-airport-4076/").toURL(); |
| 151 | + FapwizRipper ripper = new FapwizRipper(url); |
| 152 | + Assertions.assertEquals("user_used-airport-4076", ripper.getGID(url)); |
| 153 | + } |
| 154 | + |
| 155 | + @Test |
| 156 | + public void testUserGetGID4_Underscores() throws IOException, URISyntaxException { |
| 157 | + // Test a more complex username that contains underscores. |
| 158 | + URL url = new URI("https://fapwiz.com/desperate_bug_7776/").toURL(); |
| 159 | + FapwizRipper ripper = new FapwizRipper(url); |
| 160 | + Assertions.assertEquals("user_desperate_bug_7776", ripper.getGID(url)); |
| 161 | + } |
| 162 | +} |
0 commit comments