mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-16 02:44:10 +02:00
sanitizeURL can throw URISyntaxException.
This commit is contained in:
@@ -73,7 +73,7 @@ public abstract class AbstractHTMLRipper extends AbstractRipper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||
public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
|
||||
return url;
|
||||
}
|
||||
protected boolean hasDescriptionSupport() {
|
||||
|
@@ -172,7 +172,11 @@ public abstract class AbstractRipper
|
||||
if (!canRip(url)) {
|
||||
throw new MalformedURLException("Unable to rip url: " + url);
|
||||
}
|
||||
this.url = sanitizeURL(url);
|
||||
try {
|
||||
this.url = sanitizeURL(url);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new MalformedURLException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@ import java.net.URL;
|
||||
interface RipperInterface {
|
||||
void rip() throws IOException, URISyntaxException;
|
||||
boolean canRip(URL url);
|
||||
URL sanitizeURL(URL url) throws MalformedURLException;
|
||||
URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException;
|
||||
void setWorkingDir(URL url) throws IOException;
|
||||
String getHost();
|
||||
String getGID(URL url) throws MalformedURLException;
|
||||
|
@@ -2,6 +2,8 @@ package com.rarchives.ripme.ripper.rippers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -62,7 +64,7 @@ public class FlickrRipper extends AbstractHTMLRipper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||
public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
|
||||
String sUrl = url.toExternalForm();
|
||||
// Strip out https
|
||||
sUrl = sUrl.replace("https://secure.flickr.com", "http://www.flickr.com");
|
||||
@@ -73,7 +75,7 @@ public class FlickrRipper extends AbstractHTMLRipper {
|
||||
}
|
||||
sUrl += "pool";
|
||||
}
|
||||
return new URL(sUrl);
|
||||
return new URI(sUrl).toURL();
|
||||
}
|
||||
// FLickr is one of those sites what includes a api key in sites javascript
|
||||
// TODO let the user provide their own api key
|
||||
|
@@ -9,6 +9,7 @@ import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -84,7 +85,7 @@ public class LusciousRipper extends AbstractHTMLRipper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||
public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
|
||||
// Sanitizes the url removing GET parameters and convert to legacy api url.
|
||||
// "https://legacy.luscious.net/albums/albumname"
|
||||
try {
|
||||
|
Reference in New Issue
Block a user