Supporte old style of imgur account albums

http://username.imgur.com/album_title

Closes #31
This commit is contained in:
4pr0n 2014-05-02 23:13:31 -07:00
parent 535efb4d88
commit a50198c924

View File

@ -357,13 +357,6 @@ public class ImgurRipper extends AlbumRipper {
albumType = ALBUM_TYPE.USER; albumType = ALBUM_TYPE.USER;
return gid; return gid;
} }
p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{3,})\\.imgur\\.com/?$");
m = p.matcher(url.toExternalForm());
if (m.matches()) {
// Imgur account album
albumType = ALBUM_TYPE.USER_ALBUM;
return m.group();
}
p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{3,})\\.imgur\\.com/all.*$"); p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{3,})\\.imgur\\.com/all.*$");
m = p.matcher(url.toExternalForm()); m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
@ -371,6 +364,13 @@ public class ImgurRipper extends AlbumRipper {
albumType = ALBUM_TYPE.USER_IMAGES; albumType = ALBUM_TYPE.USER_IMAGES;
return m.group(1) + "_images"; return m.group(1) + "_images";
} }
p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{3,})\\.imgur\\.com/([a-zA-Z0-9\\-_]+).*$");
m = p.matcher(url.toExternalForm());
if (m.matches()) {
// Imgur account album
albumType = ALBUM_TYPE.USER_ALBUM;
return m.group(1) + "-" + m.group(2);
}
p = Pattern.compile("^https?://(www\\.)?imgur\\.com/r/([a-zA-Z0-9\\-_]{3,})(/top|/new)?(/all|/year|/month|/week)?/?$"); p = Pattern.compile("^https?://(www\\.)?imgur\\.com/r/([a-zA-Z0-9\\-_]{3,})(/top|/new)?(/all|/year|/month|/week)?/?$");
m = p.matcher(url.toExternalForm()); m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
@ -395,7 +395,7 @@ public class ImgurRipper extends AlbumRipper {
} }
return gid.replaceAll(",", "-"); return gid.replaceAll(",", "-");
} }
throw new MalformedURLException("Unexpected URL format: " + url.toExternalForm()); throw new MalformedURLException("Unsupported imgur URL format: " + url.toExternalForm());
} }
public ALBUM_TYPE getAlbumType() { public ALBUM_TYPE getAlbumType() {