diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java index 5772eb85..1a25af18 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java @@ -51,7 +51,7 @@ public abstract class AbstractRipper public abstract void rip() throws IOException, URISyntaxException; public abstract String getHost(); - public abstract String getGID(URL url) throws MalformedURLException; + public abstract String getGID(URL url) throws MalformedURLException, URISyntaxException; public boolean hasASAPRipping() { return false; } // Everytime addUrlToDownload skips a already downloaded url this increases by 1 public int alreadyDownloadedUrls = 0; @@ -551,7 +551,11 @@ public abstract class AbstractRipper * If any of those damned URLs gets malformed. */ public String getAlbumTitle(URL url) throws MalformedURLException { - return getHost() + "_" + getGID(url); + try { + return getHost() + "_" + getGID(url); + } catch (URISyntaxException e) { + throw new MalformedURLException(e.getMessage()); + } } /** diff --git a/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java b/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java index f952d010..96c352f5 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java @@ -37,7 +37,7 @@ public abstract class AlbumRipper extends AbstractRipper { public abstract URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException; public abstract void rip() throws IOException; public abstract String getHost(); - public abstract String getGID(URL url) throws MalformedURLException; + public abstract String getGID(URL url) throws MalformedURLException, URISyntaxException; protected boolean allowDuplicates() { return false; diff --git a/src/main/java/com/rarchives/ripme/ripper/RipperInterface.java b/src/main/java/com/rarchives/ripme/ripper/RipperInterface.java index cc994549..67572898 100644 --- a/src/main/java/com/rarchives/ripme/ripper/RipperInterface.java +++ b/src/main/java/com/rarchives/ripme/ripper/RipperInterface.java @@ -17,5 +17,5 @@ interface RipperInterface { URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException; void setWorkingDir(URL url) throws IOException; String getHost(); - String getGID(URL url) throws MalformedURLException; + String getGID(URL url) throws MalformedURLException, URISyntaxException; } \ No newline at end of file diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java index a9aca156..b383b97e 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java @@ -86,7 +86,12 @@ public class ImgurRipper extends AlbumRipper { } public String getAlbumTitle(URL url) throws MalformedURLException { - String gid = getGID(url); + String gid = null; + try { + gid = getGID(url); + } catch (URISyntaxException e) { + throw new MalformedURLException(e.getMessage()); + } if (this.albumType == ALBUM_TYPE.ALBUM) { try { // Attempt to use album title as GID @@ -459,7 +464,7 @@ public class ImgurRipper extends AlbumRipper { } @Override - public String getGID(URL url) throws MalformedURLException { + public String getGID(URL url) throws MalformedURLException, URISyntaxException { Pattern p; Matcher m; @@ -469,7 +474,7 @@ public class ImgurRipper extends AlbumRipper { // Imgur album or gallery albumType = ALBUM_TYPE.ALBUM; String gid = m.group(m.groupCount()); - this.url = new URL("http://imgur.com/a/" + gid); + this.url = new URI("http://imgur.com/a/" + gid).toURL(); return gid; } p = Pattern.compile("^https?://(www\\.|m\\.)?imgur\\.com/(a|gallery|t)/[a-zA-Z0-9]*/([a-zA-Z0-9]{5,}).*$"); @@ -478,7 +483,7 @@ public class ImgurRipper extends AlbumRipper { // Imgur album or gallery albumType = ALBUM_TYPE.ALBUM; String gid = m.group(m.groupCount()); - this.url = new URL("http://imgur.com/a/" + gid); + this.url = new URI("http://imgur.com/a/" + gid).toURL(); return gid; } p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{3,})\\.imgur\\.com/?$"); @@ -526,7 +531,7 @@ public class ImgurRipper extends AlbumRipper { albumType = ALBUM_TYPE.ALBUM; String subreddit = m.group(m.groupCount() - 1); String gid = m.group(m.groupCount()); - this.url = new URL("http://imgur.com/r/" + subreddit + "/" + gid); + this.url = new URI("http://imgur.com/r/" + subreddit + "/" + gid).toURL(); return "r_" + subreddit + "_" + gid; } p = Pattern.compile("^https?://(i\\.|www\\.|m\\.)?imgur\\.com/([a-zA-Z0-9]{5,})$");