Skip to content

Commit 71e20fe

Browse files
brantsparsoloturn
authored andcommitted
- Fixed Motherless ripper
- increased default retries to 3 (why only 1?) - fixed deprecation message for Motherless ripper
1 parent a178d8f commit 71e20fe

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/main/java/com/rarchives/ripme/ripper/rippers/MotherlessRipper.java

+14-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import java.net.URI;
66
import java.net.URISyntaxException;
77
import java.net.URL;
8+
import java.nio.file.Files;
9+
import java.nio.file.Paths;
810
import java.util.ArrayList;
911
import java.util.List;
1012
import java.util.regex.Matcher;
@@ -61,14 +63,17 @@ protected Document getFirstPage() throws IOException {
6163
if (!notHome) {
6264
StringBuilder newPath = new StringBuilder(path);
6365
newPath.insert(2, "M");
64-
firstURL = new URL(this.url, "https://" + DOMAIN + newPath);
66+
firstURL = URI.create("https://" + DOMAIN + newPath).toURL();
6567
LOGGER.info("Changed URL to " + firstURL);
6668
}
6769
return Http.url(firstURL).referrer("https://motherless.com").get();
6870
}
6971

7072
@Override
7173
public Document getNextPage(Document doc) throws IOException, URISyntaxException {
74+
75+
Files.write(Paths.get("doc-next-page.txt"), doc.outerHtml().getBytes());
76+
7277
Elements nextPageLink = doc.head().select("link[rel=next]");
7378
if (nextPageLink.isEmpty()) {
7479
throw new IOException("Last page reached");
@@ -111,7 +116,7 @@ protected List<String> getURLsFromPage(Document page) {
111116
@Override
112117
protected void downloadURL(URL url, int index) {
113118
// Create thread for finding image at "url" page
114-
MotherlessImageThread mit = new MotherlessImageThread(url, index);
119+
MotherlessImageRunnable mit = new MotherlessImageRunnable(url, index);
115120
motherlessThreadPool.addThread(mit);
116121
try {
117122
Thread.sleep(IMAGE_SLEEP_TIME);
@@ -150,15 +155,19 @@ public String getGID(URL url) throws MalformedURLException {
150155
throw new MalformedURLException("Expected URL format: https://motherless.com/GIXXXXXXX, got: " + url);
151156
}
152157

153-
158+
@Override
159+
protected DownloadThreadPool getThreadPool() {
160+
return motherlessThreadPool;
161+
}
162+
154163
/**
155164
* Helper class to find and download images found on "image" pages
156165
*/
157-
private class MotherlessImageThread implements Runnable {
166+
private class MotherlessImageRunnable implements Runnable {
158167
private final URL url;
159168
private final int index;
160169

161-
MotherlessImageThread(URL url, int index) {
170+
MotherlessImageRunnable(URL url, int index) {
162171
super();
163172
this.url = url;
164173
this.index = index;

src/main/java/com/rarchives/ripme/utils/Http.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static Http url(URL url) {
5656
}
5757

5858
private void defaultSettings() {
59-
this.retries = Utils.getConfigInteger("download.retries", 1);
59+
this.retries = Utils.getConfigInteger("download.retries", 3);
6060
this.retrySleep = Utils.getConfigInteger("download.retry.sleep", 5000);
6161
connection = Jsoup.connect(this.url);
6262
connection.userAgent(AbstractRipper.USER_AGENT);

src/main/resources/rip.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ threads.size = 5
66
file.overwrite = false
77

88
# Number of retries on failed downloads
9-
download.retries = 1
9+
download.retries = 3
1010

1111
# File download timeout (in milliseconds)
1212
download.timeout = 60000

0 commit comments

Comments
 (0)