1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-28 08:10:11 +02:00

new URL is deprecated, use new URI, setGID, imgur

This commit is contained in:
soloturn
2023-06-15 15:07:09 +02:00
parent 07178479e9
commit 029b03c74d
4 changed files with 18 additions and 9 deletions

View File

@@ -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());
}
}
/**

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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,})$");