1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-18 19:51:35 +02:00

new URI instead of new URL, pornhub, sta.

This commit is contained in:
soloturn
2023-12-09 16:13:03 +01:00
parent 8b9e4b98de
commit 43ebb8d643
2 changed files with 14 additions and 10 deletions

View File

@@ -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.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
@@ -47,12 +49,12 @@ public class PornhubRipper extends AbstractHTMLRipper {
} }
@Override @Override
public Document getNextPage(Document page) throws IOException { public Document getNextPage(Document page) throws IOException, URISyntaxException {
Elements nextPageLink = page.select("li.page_next > a"); Elements nextPageLink = page.select("li.page_next > a");
if (nextPageLink.isEmpty()){ if (nextPageLink.isEmpty()){
throw new IOException("No more pages"); throw new IOException("No more pages");
} else { } else {
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).get(); return Http.url(nextURL).get();
} }
} }
@@ -83,13 +85,13 @@ public class PornhubRipper extends AbstractHTMLRipper {
} }
} }
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;
} }
@@ -159,10 +161,10 @@ public class PornhubRipper extends AbstractHTMLRipper {
prefix = String.format("%03d_", index); prefix = String.format("%03d_", index);
} }
URL imgurl = new URL(url, imgsrc); URL imgurl = url.toURI().resolve(imgsrc).toURL();
addURLToDownload(imgurl, prefix); addURLToDownload(imgurl, prefix);
} 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);
} }
} }

View File

@@ -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.HashMap; import java.util.HashMap;
@@ -55,10 +57,10 @@ public class StaRipper extends AbstractHTMLRipper {
Document thumbPage = null; Document thumbPage = null;
if (checkURL(thumbPageURL)) { if (checkURL(thumbPageURL)) {
try { try {
Connection.Response resp = Http.url(new URL(thumbPageURL)).response(); Connection.Response resp = Http.url(new URI(thumbPageURL).toURL()).response();
cookies.putAll(resp.cookies()); cookies.putAll(resp.cookies());
thumbPage = resp.parse(); thumbPage = resp.parse();
} catch (MalformedURLException e) { } catch (MalformedURLException | URISyntaxException e) {
LOGGER.info(thumbPageURL + " is a malformed URL"); LOGGER.info(thumbPageURL + " is a malformed URL");
} catch (IOException e) { } catch (IOException e) {
LOGGER.info(e.getMessage()); LOGGER.info(e.getMessage());
@@ -75,9 +77,9 @@ public class StaRipper extends AbstractHTMLRipper {
private boolean checkURL(String url) { private boolean checkURL(String url) {
try { try {
new URL(url); new URI(url).toURL();
return true; return true;
} catch (MalformedURLException e) { } catch (MalformedURLException | URISyntaxException e) {
return false; return false;
} }
} }