Imgur: Accept /gallery/ URLs

This commit is contained in:
4pr0n 2015-12-21 07:36:28 -08:00
parent d81dbed0f3
commit 22cee44345
2 changed files with 12 additions and 1 deletions

View File

@ -73,6 +73,7 @@ public class ImgurRipper extends AlbumRipper {
if (u.indexOf('#') >= 0) { if (u.indexOf('#') >= 0) {
u = u.substring(0, u.indexOf('#')); u = u.substring(0, u.indexOf('#'));
} }
u = u.replace("imgur.com/gallery/", "imgur.com/a/");
u = u.replace("https?://m\\.imgur\\.com", "http://imgur.com"); u = u.replace("https?://m\\.imgur\\.com", "http://imgur.com");
u = u.replace("https?://i\\.imgur\\.com", "http://imgur.com"); u = u.replace("https?://i\\.imgur\\.com", "http://imgur.com");
return new URL(u); return new URL(u);
@ -370,6 +371,15 @@ public class ImgurRipper extends AlbumRipper {
this.url = new URL("http://imgur.com/a/" + gid); this.url = new URL("http://imgur.com/a/" + gid);
return gid; return gid;
} }
p = Pattern.compile("^https?://(m\\.)?imgur\\.com/gallery/([a-zA-Z0-9]{5,8}).*$");
m = p.matcher(url.toExternalForm());
if (m.matches()) {
// Imgur gallery
albumType = ALBUM_TYPE.ALBUM;
String gid = m.group(m.groupCount());
this.url = new URL("http://imgur.com/a/" + gid);
return gid;
}
p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{3,})\\.imgur\\.com/?$"); p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{3,})\\.imgur\\.com/?$");
m = p.matcher(url.toExternalForm()); m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {

View File

@ -38,9 +38,10 @@ public class ImgurRipperTest extends RippersTest {
contentURLs.add(new URL("http://imgur.com/a/WxG6f/layout/vertical#0")); contentURLs.add(new URL("http://imgur.com/a/WxG6f/layout/vertical#0"));
contentURLs.add(new URL("http://imgur.com/a/WxG6f/layout/horizontal#0")); contentURLs.add(new URL("http://imgur.com/a/WxG6f/layout/horizontal#0"));
contentURLs.add(new URL("http://imgur.com/a/WxG6f/layout/grid#0")); contentURLs.add(new URL("http://imgur.com/a/WxG6f/layout/grid#0"));
contentURLs.add(new URL("http://imgur.com/gallery/FmP2o")); // Gallery URL
// Sometimes hangs up // Sometimes hangs up
//contentURLs.add(new URL("http://imgur.com/r/nsfw_oc/top/all")); //contentURLs.add(new URL("http://imgur.com/r/nsfw_oc/top/all"));
contentURLs.add(new URL("http://imgur.com/a/bXQpH")); contentURLs.add(new URL("http://imgur.com/a/bXQpH")); // Album with titles/descriptions
for (URL url : contentURLs) { for (URL url : contentURLs) {
ImgurRipper ripper = new ImgurRipper(url); ImgurRipper ripper = new ImgurRipper(url);
testRipper(ripper); testRipper(ripper);