From 1bd9885fbaaa594844b883ef0d4d5f10eb3a1281 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Fri, 13 Apr 2018 18:33:31 -0400 Subject: [PATCH 1/5] Added ripper for Blackbrickroadofoz.com --- .../ripper/rippers/Blackbrickroadofoz.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java b/src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java new file mode 100644 index 00000000..c290170f --- /dev/null +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java @@ -0,0 +1,80 @@ +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 Blackbrickroadofoz extends AbstractHTMLRipper { + + public Blackbrickroadofoz(URL url) throws IOException { + super(url); + } + + @Override + public String getHost() { + return "cfake"; + } + + @Override + public String getDomain() { + return "cfake.com"; + } + + @Override + public String getGID(URL url) throws MalformedURLException { + Pattern p = Pattern.compile("https?://www.blackbrickroadofoz.com/comic/([a-zA-Z0-9_-]*)/?$"); + Matcher m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return m.group(1); + } + throw new MalformedURLException("Expected blackbrickroadofoz URL format: " + + "www.blackbrickroadofoz.com/comic/PAGE - 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 { + Element elem = doc.select("nav.cc-nav > a.cc-next").first(); + if (elem == null) { + throw new IOException("No more pages"); + } + String nextPage = elem.attr("href"); + // Some times this returns a empty string + // This for stops that + if (nextPage == "") { + throw new IOException("No more pages"); + } + else { + return Http.url(nextPage).get(); + } + } + + @Override + public List getURLsFromPage(Document doc) { + List result = new ArrayList<>(); + Element elem = doc.select("img[id=cc-comic]").first(); + result.add(elem.attr("src")); + + return result; + } + + @Override + public void downloadURL(URL url, int index) { + addURLToDownload(url, getPrefix(index)); + } +} From d8254b6e03c84551e6de206bcb3ef52bac601505 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Fri, 13 Apr 2018 18:52:38 -0400 Subject: [PATCH 2/5] Fixed url encoding error with Blackbrickroadofoz --- .../ripme/ripper/rippers/Blackbrickroadofoz.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java b/src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java index c290170f..2c9b14eb 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java @@ -22,12 +22,12 @@ public class Blackbrickroadofoz extends AbstractHTMLRipper { @Override public String getHost() { - return "cfake"; + return "blackbrickroadofoz"; } @Override public String getDomain() { - return "cfake.com"; + return "blackbrickroadofoz.com"; } @Override @@ -49,7 +49,8 @@ public class Blackbrickroadofoz extends AbstractHTMLRipper { @Override public Document getNextPage(Document doc) throws IOException { - Element elem = doc.select("nav.cc-nav > a.cc-next").first(); + sleep(1000); + Element elem = doc.select("div[id=topnav] > nav.cc-nav > a.cc-next").first(); if (elem == null) { throw new IOException("No more pages"); } @@ -67,8 +68,9 @@ public class Blackbrickroadofoz extends AbstractHTMLRipper { @Override public List getURLsFromPage(Document doc) { List result = new ArrayList<>(); - Element elem = doc.select("img[id=cc-comic]").first(); - result.add(elem.attr("src")); + Element elem = doc.select("div[id=cc-comicbody] > a > img[id=cc-comic]").first(); + // The site doesn't return properly encoded urls we replace all spaces ( ) with %20 + result.add(elem.attr("src").replaceAll(" ", "%20")); return result; } From 8cd3f5d77a22c880f23a3d4c9b734db8bb796b95 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Fri, 13 Apr 2018 18:54:27 -0400 Subject: [PATCH 3/5] Renamed misnamed file --- ...{Blackbrickroadofoz.java => BlackbrickroadofozRipper.java} | 0 .../tst/ripper/rippers/BlackbrickroadofozRipperTest.java | 4 ++++ 2 files changed, 4 insertions(+) rename src/main/java/com/rarchives/ripme/ripper/rippers/{Blackbrickroadofoz.java => BlackbrickroadofozRipper.java} (100%) create mode 100644 src/test/java/com/rarchives/ripme/tst/ripper/rippers/BlackbrickroadofozRipperTest.java diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java b/src/main/java/com/rarchives/ripme/ripper/rippers/BlackbrickroadofozRipper.java similarity index 100% rename from src/main/java/com/rarchives/ripme/ripper/rippers/Blackbrickroadofoz.java rename to src/main/java/com/rarchives/ripme/ripper/rippers/BlackbrickroadofozRipper.java diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BlackbrickroadofozRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BlackbrickroadofozRipperTest.java new file mode 100644 index 00000000..2c479c36 --- /dev/null +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BlackbrickroadofozRipperTest.java @@ -0,0 +1,4 @@ +package com.rarchives.ripme.tst.ripper.rippers; + +public class BlackbrickroadofozRipperTest { +} From d16424d936b12e0b49fe7919ef40a94e3a7702de Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Fri, 13 Apr 2018 18:55:19 -0400 Subject: [PATCH 4/5] Renamed misnamed class --- .../ripme/ripper/rippers/BlackbrickroadofozRipper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/BlackbrickroadofozRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/BlackbrickroadofozRipper.java index 2c9b14eb..76340cf9 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/BlackbrickroadofozRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/BlackbrickroadofozRipper.java @@ -14,9 +14,9 @@ import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AbstractHTMLRipper; import com.rarchives.ripme.utils.Http; -public class Blackbrickroadofoz extends AbstractHTMLRipper { +public class BlackbrickroadofozRipper extends AbstractHTMLRipper { - public Blackbrickroadofoz(URL url) throws IOException { + public BlackbrickroadofozRipper(URL url) throws IOException { super(url); } From cbc286170e4f78a793a4351657ea888683574feb Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Fri, 13 Apr 2018 18:57:57 -0400 Subject: [PATCH 5/5] Added unit test for Blackbrickroadofoz Ripper --- .../ripper/rippers/BlackbrickroadofozRipperTest.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BlackbrickroadofozRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BlackbrickroadofozRipperTest.java index 2c479c36..a3c7d862 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BlackbrickroadofozRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/BlackbrickroadofozRipperTest.java @@ -1,4 +1,13 @@ package com.rarchives.ripme.tst.ripper.rippers; -public class BlackbrickroadofozRipperTest { +import com.rarchives.ripme.ripper.rippers.BlackbrickroadofozRipper; + +import java.io.IOException; +import java.net.URL; + +public class BlackbrickroadofozRipperTest extends RippersTest { + public void testRip() throws IOException { + BlackbrickroadofozRipper ripper = new BlackbrickroadofozRipper(new URL("http://www.blackbrickroadofoz.com/comic/beginning")); + testRipper(ripper); + } }