From 149ab50dc1249099013bb4d9d86602552803f943 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 16 Nov 2017 13:58:21 -0500 Subject: [PATCH 1/5] Added basic pichunter ripper --- .../ripme/ripper/rippers/PichunterRipper.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java new file mode 100644 index 00000000..160d5507 --- /dev/null +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java @@ -0,0 +1,74 @@ +package com.rarchives.ripme.ripper.rippers; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; + +import com.rarchives.ripme.ripper.AbstractHTMLRipper; +import com.rarchives.ripme.utils.Http; + +public class PichunterRipper extends AbstractHTMLRipper { + + public PichunterRipper(URL url) throws IOException { + super(url); + } + + @Override + public String getHost() { + return "pichunter"; + } + + @Override + public String getDomain() { + return "pichunter.com"; + } + + @Override + public String getGID(URL url) throws MalformedURLException { + Pattern p = Pattern.compile("https?://www.pichunter.com/(tags|models|sites)/([a-zA-Z0-9_-]+)/?"); + Matcher m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return m.group(2); + } + throw new MalformedURLException("Expected pichunter URL format: " + + "pichunter.com/(tags|models|sites)/Name/ - got " + url + " instead"); + } + + @Override + public Document getFirstPage() throws IOException { + // "url" is an instance field of the superclass + return Http.url(url).get(); + } + + @Override + public Document getNextPage(Document doc) throws IOException { + // We use comic-nav-next to the find the next page + Element elem = doc.select("div.paperSpacings > ul > li.arrow").last(); + + String nextPage = elem.select("a").attr("href"); + // Some times this returns a empty string + // This for stops that + return Http.url("http://www.pichunter.com" + nextPage).get(); + } + + @Override + public List getURLsFromPage(Document doc) { + List result = new ArrayList<>(); + for (Element el : doc.select("div.thumbtable > a.thumb > img")) { + result.add(el.attr("src").replaceAll("_i", "_o")); + } + return result; + } + + @Override + public void downloadURL(URL url, int index) { + addURLToDownload(url, getPrefix(index)); + } +} \ No newline at end of file From fc5d4b7533cb86550cd53e45d5fcfd0b1d94a973 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 16 Nov 2017 14:09:03 -0500 Subject: [PATCH 2/5] pichunter ripper no longer errors out on last page --- .../ripme/ripper/rippers/PichunterRipper.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java index 160d5507..70ec151a 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java @@ -37,6 +37,11 @@ public class PichunterRipper extends AbstractHTMLRipper { if (m.matches()) { return m.group(2); } + p = Pattern.compile("https?://www.pichunter.com/(tags|models|sites)/([a-zA-Z0-9_-]+)/photos/\\d+/?"); + m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return m.group(2); + } throw new MalformedURLException("Expected pichunter URL format: " + "pichunter.com/(tags|models|sites)/Name/ - got " + url + " instead"); } @@ -51,11 +56,13 @@ public class PichunterRipper extends AbstractHTMLRipper { public Document getNextPage(Document doc) throws IOException { // We use comic-nav-next to the find the next page Element elem = doc.select("div.paperSpacings > ul > li.arrow").last(); - - String nextPage = elem.select("a").attr("href"); - // Some times this returns a empty string - // This for stops that - return Http.url("http://www.pichunter.com" + nextPage).get(); + if (elem != null) { + String nextPage = elem.select("a").attr("href"); + // Some times this returns a empty string + // This for stops that + return Http.url("http://www.pichunter.com" + nextPage).get(); + } + throw new IOException("No more pages"); } @Override From 1dc90693a7d3e0866da7d6c4a1ca9ae51908103b Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 16 Nov 2017 14:18:52 -0500 Subject: [PATCH 3/5] Added unit test for pichunter --- .../ripme/tst/ripper/rippers/BasicRippersTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BasicRippersTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BasicRippersTest.java index 1ba98059..8f5bc1d0 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BasicRippersTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BasicRippersTest.java @@ -28,6 +28,7 @@ import com.rarchives.ripme.ripper.rippers.VidbleRipper; import com.rarchives.ripme.ripper.rippers.VineRipper; import com.rarchives.ripme.ripper.rippers.VkRipper; import com.rarchives.ripme.ripper.rippers.XhamsterRipper; +import com.rarchives.ripme.ripper.rippers.PichunterRipper; /** * Simple test cases for various rippers. @@ -192,6 +193,11 @@ public class BasicRippersTest extends RippersTest { testRipper(ripper); } + public void testPichunterRip() throws IOException { + AbstractRipper ripper = new PichunterRipper(new URL("http://www.pichunter.com/tags/all/Sex/14")); + testRipper(ripper); + } + public void testMotherlessAlbumRip() throws IOException { MotherlessRipper ripper = new MotherlessRipper(new URL("http://motherless.com/G4DAA18D")); testRipper(ripper); From a031ffe4122f94a04d30b9075f3775e580e52691 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 16 Nov 2017 14:35:10 -0500 Subject: [PATCH 4/5] Fixed pichunter test --- .../rarchives/ripme/tst/ripper/rippers/BasicRippersTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BasicRippersTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BasicRippersTest.java index 8f5bc1d0..c191f5fa 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BasicRippersTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BasicRippersTest.java @@ -194,7 +194,7 @@ public class BasicRippersTest extends RippersTest { } public void testPichunterRip() throws IOException { - AbstractRipper ripper = new PichunterRipper(new URL("http://www.pichunter.com/tags/all/Sex/14")); + AbstractRipper ripper = new PichunterRipper(new URL("https://www.pichunter.com/models/Madison_Ivy")); testRipper(ripper); } From 9837f893f12417fe1a3b381d53137442b30abfa3 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 16 Nov 2017 14:35:40 -0500 Subject: [PATCH 5/5] pichunter now supports all album types --- .../rarchives/ripme/ripper/rippers/PichunterRipper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java index 70ec151a..06656698 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java @@ -32,7 +32,7 @@ public class PichunterRipper extends AbstractHTMLRipper { @Override public String getGID(URL url) throws MalformedURLException { - Pattern p = Pattern.compile("https?://www.pichunter.com/(tags|models|sites)/([a-zA-Z0-9_-]+)/?"); + Pattern p = Pattern.compile("https?://www.pichunter.com/(|tags|models|sites)/([a-zA-Z0-9_-]+)/?"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(2); @@ -42,6 +42,11 @@ public class PichunterRipper extends AbstractHTMLRipper { if (m.matches()) { return m.group(2); } + p = Pattern.compile("https?://www.pichunter.com/tags/all/([a-zA-Z0-9_-]+)/\\d+/?"); + m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return m.group(1); + } throw new MalformedURLException("Expected pichunter URL format: " + "pichunter.com/(tags|models|sites)/Name/ - got " + url + " instead"); }