mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-23 22:14:06 +02:00
new URI in App, Http, RipUtils.
This commit is contained in:
@@ -24,6 +24,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -183,7 +184,7 @@ public class App {
|
|||||||
}
|
}
|
||||||
for (HistoryEntry entry : HISTORY.toList()) {
|
for (HistoryEntry entry : HISTORY.toList()) {
|
||||||
try {
|
try {
|
||||||
URL url = new URL(entry.url);
|
URL url = new URI(entry.url).toURL();
|
||||||
rip(url);
|
rip(url);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("[!] Failed to rip URL " + entry.url, e);
|
logger.error("[!] Failed to rip URL " + entry.url, e);
|
||||||
@@ -212,7 +213,7 @@ public class App {
|
|||||||
if (entry.selected) {
|
if (entry.selected) {
|
||||||
added++;
|
added++;
|
||||||
try {
|
try {
|
||||||
URL url = new URL(entry.url);
|
URL url = new URI(entry.url).toURL();
|
||||||
rip(url);
|
rip(url);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("[!] Failed to rip URL " + entry.url, e);
|
logger.error("[!] Failed to rip URL " + entry.url, e);
|
||||||
@@ -290,7 +291,7 @@ public class App {
|
|||||||
*/
|
*/
|
||||||
private static void ripURL(String targetURL, boolean saveConfig) {
|
private static void ripURL(String targetURL, boolean saveConfig) {
|
||||||
try {
|
try {
|
||||||
URL url = new URL(targetURL);
|
URL url = new URI(targetURL).toURL();
|
||||||
rip(url);
|
rip(url);
|
||||||
saveHistory();
|
saveHistory();
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
|
@@ -15,6 +15,8 @@ import org.jsoup.nodes.Document;
|
|||||||
|
|
||||||
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.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -73,7 +75,7 @@ public class Http {
|
|||||||
|
|
||||||
String cookieDomain = "";
|
String cookieDomain = "";
|
||||||
try {
|
try {
|
||||||
URL parsed = new URL(u);
|
URL parsed = new URI(u).toURL();
|
||||||
String cookieStr = "";
|
String cookieStr = "";
|
||||||
|
|
||||||
String[] parts = parsed.getHost().split("\\.");
|
String[] parts = parsed.getHost().split("\\.");
|
||||||
@@ -97,7 +99,7 @@ public class Http {
|
|||||||
if (!cookieStr.equals("")) {
|
if (!cookieStr.equals("")) {
|
||||||
cookiesParsed = RipUtils.getCookiesFromString(cookieStr.trim());
|
cookiesParsed = RipUtils.getCookiesFromString(cookieStr.trim());
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
logger.warn("Parsing url " + u + " while getting cookies", e);
|
logger.warn("Parsing url " + u + " while getting cookies", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,6 +2,8 @@ package com.rarchives.ripme.utils;
|
|||||||
|
|
||||||
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.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -60,8 +62,8 @@ public class RipUtils {
|
|||||||
} else if (url.getHost().endsWith("i.imgur.com") && url.toExternalForm().contains("gifv")) {
|
} else if (url.getHost().endsWith("i.imgur.com") && url.toExternalForm().contains("gifv")) {
|
||||||
// links to imgur gifvs
|
// links to imgur gifvs
|
||||||
try {
|
try {
|
||||||
result.add(new URL(url.toExternalForm().replaceAll(".gifv", ".mp4")));
|
result.add(new URI(url.toExternalForm().replaceAll(".gifv", ".mp4")).toURL());
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
logger.info("Couldn't get gifv from " + url);
|
logger.info("Couldn't get gifv from " + url);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -72,8 +74,8 @@ public class RipUtils {
|
|||||||
logger.debug("Fetching gfycat page " + url);
|
logger.debug("Fetching gfycat page " + url);
|
||||||
String videoURL = GfycatRipper.getVideoURL(url);
|
String videoURL = GfycatRipper.getVideoURL(url);
|
||||||
logger.debug("Got gfycat URL: " + videoURL);
|
logger.debug("Got gfycat URL: " + videoURL);
|
||||||
result.add(new URL(videoURL));
|
result.add(new URI(videoURL).toURL());
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
logger.warn("Exception while retrieving gfycat page:", e);
|
logger.warn("Exception while retrieving gfycat page:", e);
|
||||||
}
|
}
|
||||||
@@ -84,8 +86,8 @@ public class RipUtils {
|
|||||||
logger.debug("Fetching redgifs page " + url);
|
logger.debug("Fetching redgifs page " + url);
|
||||||
String videoURL = RedgifsRipper.getVideoURL(url);
|
String videoURL = RedgifsRipper.getVideoURL(url);
|
||||||
logger.debug("Got redgifs URL: " + videoURL);
|
logger.debug("Got redgifs URL: " + videoURL);
|
||||||
result.add(new URL(videoURL));
|
result.add(new URI(videoURL).toURL());
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
logger.warn("Exception while retrieving redgifs page:", e);
|
logger.warn("Exception while retrieving redgifs page:", e);
|
||||||
}
|
}
|
||||||
@@ -121,9 +123,9 @@ public class RipUtils {
|
|||||||
EromeRipper r = new EromeRipper(url);
|
EromeRipper r = new EromeRipper(url);
|
||||||
Document tempDoc = r.getFirstPage();
|
Document tempDoc = r.getFirstPage();
|
||||||
for (String u : r.getURLsFromPage(tempDoc)) {
|
for (String u : r.getURLsFromPage(tempDoc)) {
|
||||||
result.add(new URL(u));
|
result.add(new URI(u).toURL());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
logger.warn("Exception while retrieving eroshare page:", e);
|
logger.warn("Exception while retrieving eroshare page:", e);
|
||||||
}
|
}
|
||||||
@@ -135,9 +137,9 @@ public class RipUtils {
|
|||||||
SoundgasmRipper r = new SoundgasmRipper(url);
|
SoundgasmRipper r = new SoundgasmRipper(url);
|
||||||
Document tempDoc = r.getFirstPage();
|
Document tempDoc = r.getFirstPage();
|
||||||
for (String u : r.getURLsFromPage(tempDoc)) {
|
for (String u : r.getURLsFromPage(tempDoc)) {
|
||||||
result.add(new URL(u));
|
result.add(new URI(u).toURL());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
logger.warn("Exception while retrieving soundgasm page:", e);
|
logger.warn("Exception while retrieving soundgasm page:", e);
|
||||||
}
|
}
|
||||||
@@ -150,8 +152,8 @@ public class RipUtils {
|
|||||||
logger.info("URL: " + url.toExternalForm());
|
logger.info("URL: " + url.toExternalForm());
|
||||||
String u = url.toExternalForm().replaceAll("&", "&");
|
String u = url.toExternalForm().replaceAll("&", "&");
|
||||||
try {
|
try {
|
||||||
result.add(new URL(u));
|
result.add(new URI(u).toURL());
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -161,11 +163,11 @@ public class RipUtils {
|
|||||||
m = p.matcher(url.toExternalForm());
|
m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
try {
|
try {
|
||||||
URL singleURL = new URL(m.group(1));
|
URL singleURL = new URI(m.group(1)).toURL();
|
||||||
logger.debug("Found single URL: " + singleURL);
|
logger.debug("Found single URL: " + singleURL);
|
||||||
result.add(singleURL);
|
result.add(singleURL);
|
||||||
return result;
|
return result;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
logger.error("[!] Not a valid URL: '" + url + "'", e);
|
logger.error("[!] Not a valid URL: '" + url + "'", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,19 +181,19 @@ public class RipUtils {
|
|||||||
.get();
|
.get();
|
||||||
for (Element el : doc.select("meta")) {
|
for (Element el : doc.select("meta")) {
|
||||||
if (el.attr("property").equals("og:video")) {
|
if (el.attr("property").equals("og:video")) {
|
||||||
result.add(new URL(el.attr("content")));
|
result.add(new URI(el.attr("content")).toURL());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (el.attr("name").equals("twitter:image:src")) {
|
else if (el.attr("name").equals("twitter:image:src")) {
|
||||||
result.add(new URL(el.attr("content")));
|
result.add(new URI(el.attr("content")).toURL());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (el.attr("name").equals("twitter:image")) {
|
else if (el.attr("name").equals("twitter:image")) {
|
||||||
result.add(new URL(el.attr("content")));
|
result.add(new URI(el.attr("content")).toURL());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
logger.error("[!] Error", ex);
|
logger.error("[!] Error", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user