mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-19 12:11:40 +02:00
new URI instead of new URL, motherless, nfsfw.
This commit is contained in:
@@ -2,6 +2,8 @@ package com.rarchives.ripme.ripper.rippers;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -66,13 +68,13 @@ public class MotherlessRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Document getNextPage(Document doc) throws IOException {
|
public Document getNextPage(Document doc) throws IOException, URISyntaxException {
|
||||||
Elements nextPageLink = doc.head().select("link[rel=next]");
|
Elements nextPageLink = doc.head().select("link[rel=next]");
|
||||||
if (nextPageLink.isEmpty()) {
|
if (nextPageLink.isEmpty()) {
|
||||||
throw new IOException("Last page reached");
|
throw new IOException("Last page reached");
|
||||||
} else {
|
} else {
|
||||||
String referrerLink = doc.head().select("link[rel=canonical]").first().attr("href");
|
String referrerLink = doc.head().select("link[rel=canonical]").first().attr("href");
|
||||||
URL nextURL = new URL(this.url, nextPageLink.first().attr("href"));
|
URL nextURL = this.url.toURI().resolve(nextPageLink.first().attr("href")).toURL();
|
||||||
return Http.url(nextURL).referrer(referrerLink).get();
|
return Http.url(nextURL).referrer(referrerLink).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,11 +182,11 @@ public class MotherlessRipper extends AbstractHTMLRipper {
|
|||||||
if (Utils.getConfigBoolean("download.save_order", true)) {
|
if (Utils.getConfigBoolean("download.save_order", true)) {
|
||||||
prefix = String.format("%03d_", index);
|
prefix = String.format("%03d_", index);
|
||||||
}
|
}
|
||||||
addURLToDownload(new URL(file), prefix);
|
addURLToDownload(new URI(file).toURL(), prefix);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warn("[!] could not find '__fileurl' at " + url);
|
LOGGER.warn("[!] could not find '__fileurl' at " + url);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
LOGGER.error("[!] Exception while loading/parsing " + this.url, e);
|
LOGGER.error("[!] Exception while loading/parsing " + this.url, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,8 @@ package com.rarchives.ripme.ripper.rippers;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -104,13 +106,13 @@ public class NfsfwRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
|
||||||
// always start on the first page of an album
|
// always start on the first page of an album
|
||||||
// (strip the options after the '?')
|
// (strip the options after the '?')
|
||||||
String u = url.toExternalForm();
|
String u = url.toExternalForm();
|
||||||
if (u.contains("?")) {
|
if (u.contains("?")) {
|
||||||
u = u.substring(0, u.indexOf("?"));
|
u = u.substring(0, u.indexOf("?"));
|
||||||
return new URL(u);
|
return new URI(u).toURL();
|
||||||
} else {
|
} else {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@@ -220,8 +222,8 @@ public class NfsfwRipper extends AbstractHTMLRipper {
|
|||||||
if (file.startsWith("/")) {
|
if (file.startsWith("/")) {
|
||||||
file = "http://nfsfw.com" + file;
|
file = "http://nfsfw.com" + file;
|
||||||
}
|
}
|
||||||
addURLToDownload(new URL(file), getPrefix(index), this.subdir);
|
addURLToDownload(new URI(file).toURL(), getPrefix(index), this.subdir);
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
LOGGER.error("[!] Exception while loading/parsing " + this.url, e);
|
LOGGER.error("[!] Exception while loading/parsing " + this.url, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user