1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-21 13:11:27 +02:00

new URI instead of new URL, E621.

This commit is contained in:
soloturn
2023-12-29 12:16:08 +01:00
parent d1166a73bf
commit 65f0f0e562

View File

@@ -10,6 +10,8 @@ import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
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.HashMap; import java.util.HashMap;
@@ -181,14 +183,14 @@ public class E621Ripper extends AbstractHTMLRipper {
} }
@Override @Override
public URL sanitizeURL(URL url) throws MalformedURLException { public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
if (gidPattern2 == null) if (gidPattern2 == null)
gidPattern2 = Pattern.compile( gidPattern2 = Pattern.compile(
"^https?://(www\\.)?e621\\.net/post/search\\?tags=([a-zA-Z0-9$_.+!*'():,%-]+)(/.*)?(#.*)?$"); "^https?://(www\\.)?e621\\.net/post/search\\?tags=([a-zA-Z0-9$_.+!*'():,%-]+)(/.*)?(#.*)?$");
Matcher m = gidPattern2.matcher(url.toExternalForm()); Matcher m = gidPattern2.matcher(url.toExternalForm());
if (m.matches()) if (m.matches())
return new URL("https://e621.net/post/index/1/" + m.group(2).replace("+", "%20")); return new URI("https://e621.net/post/index/1/" + m.group(2).replace("+", "%20")).toURL();
return url; return url;
} }
@@ -208,9 +210,9 @@ public class E621Ripper extends AbstractHTMLRipper {
try { try {
String fullSizedImage = getFullSizedImage(url); String fullSizedImage = getFullSizedImage(url);
if (fullSizedImage != null && !fullSizedImage.equals("")) { if (fullSizedImage != null && !fullSizedImage.equals("")) {
addURLToDownload(new URL(fullSizedImage), index); addURLToDownload(new URI(fullSizedImage).toURL(), index);
} }
} catch (IOException e) { } catch (IOException | URISyntaxException e) {
logger.error("Unable to get full sized image from " + url); logger.error("Unable to get full sized image from " + url);
} }
} }