Skip to content

Commit

Permalink
new URI instead of new URL, E621.
Browse files Browse the repository at this point in the history
  • Loading branch information
soloturn committed Dec 29, 2023
1 parent d1166a7 commit 65f0f0e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/rarchives/ripme/ripper/rippers/E621Ripper.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -181,14 +183,14 @@ public String getGID(URL url) throws MalformedURLException {
}

@Override
public URL sanitizeURL(URL url) throws MalformedURLException {
public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
if (gidPattern2 == null)
gidPattern2 = Pattern.compile(
"^https?://(www\\.)?e621\\.net/post/search\\?tags=([a-zA-Z0-9$_.+!*'():,%-]+)(/.*)?(#.*)?$");

Matcher m = gidPattern2.matcher(url.toExternalForm());
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;
}
Expand All @@ -208,9 +210,9 @@ public void run() {
try {
String fullSizedImage = getFullSizedImage(url);
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);
}
}
Expand Down

0 comments on commit 65f0f0e

Please sign in to comment.