Skip to content

Commit 1cdec76

Browse files
committed
Support multi-page motherless albums
1 parent e975ae6 commit 1cdec76

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,36 @@ public URL sanitizeURL(URL url) throws MalformedURLException {
4747

4848
@Override
4949
public String getGID(URL url) throws MalformedURLException {
50-
Pattern p = Pattern.compile("^https?://(www\\.)?motherless\\.com/G([A-Z0-9]{6,8}).*$");
50+
Pattern p = Pattern.compile("^https?://(www\\.)?motherless\\.com/G([VI][A-F0-9]{6,8}).*$");
5151
Matcher m = p.matcher(url.toExternalForm());
5252
if (!m.matches()) {
53-
throw new MalformedURLException("Expected URL format: http://motherless.com/GXXXXXXXX");
53+
throw new MalformedURLException("Expected URL format: http://motherless.com/GIXXXXXXX, got: " + url);
5454
}
5555
return m.group(m.groupCount());
5656
}
5757

5858
@Override
5959
public void rip() throws IOException {
60-
int index = 0;
61-
logger.info(" Retrieving " + this.url.toExternalForm());
62-
Document doc = Jsoup.connect(this.url.toExternalForm())
63-
.userAgent(USER_AGENT)
64-
.get();
65-
for (Element thumb : doc.select("div.thumb a.img-container")) {
66-
URL url = new URL("http://" + DOMAIN + thumb.attr("href"));
67-
index += 1;
68-
// Create thread for finding image at "url" page
69-
MotherlessImageThread mit = new MotherlessImageThread(url, index);
70-
motherlessThreadPool.addThread(mit);
60+
int index = 0, page = 1;
61+
String nextURL = this.url.toExternalForm();
62+
while (nextURL != null) {
63+
logger.info(" Retrieving " + nextURL);
64+
Document doc = Jsoup.connect(nextURL)
65+
.userAgent(USER_AGENT)
66+
.get();
67+
for (Element thumb : doc.select("div.thumb a.img-container")) {
68+
URL url = new URL("http://" + DOMAIN + thumb.attr("href"));
69+
index += 1;
70+
// Create thread for finding image at "url" page
71+
MotherlessImageThread mit = new MotherlessImageThread(url, index);
72+
motherlessThreadPool.addThread(mit);
73+
}
74+
// Next page
75+
nextURL = null;
76+
page++;
77+
if (doc.html().contains("?page=" + page)) {
78+
nextURL = this.url.toExternalForm() + "?page=" + page;
79+
}
7180
}
7281
motherlessThreadPool.waitForThreads();
7382
waitForThreads();

0 commit comments

Comments
 (0)