Skip to content

Commit

Permalink
Supporte old style of imgur account albums
Browse files Browse the repository at this point in the history
  • Loading branch information
4pr0n committed May 3, 2014
1 parent 535efb4 commit a50198c
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,20 +357,20 @@ public String getGID(URL url) throws MalformedURLException {
albumType = ALBUM_TYPE.USER;
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.*$");
m = p.matcher(url.toExternalForm());
if (m.matches()) {
// Imgur account images
albumType = ALBUM_TYPE.USER_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)?/?$");
m = p.matcher(url.toExternalForm());
if (m.matches()) {
Expand All @@ -395,7 +395,7 @@ public String getGID(URL url) throws MalformedURLException {
}
return gid.replaceAll(",", "-");
}
throw new MalformedURLException("Unexpected URL format: " + url.toExternalForm());
throw new MalformedURLException("Unsupported imgur URL format: " + url.toExternalForm());
}

public ALBUM_TYPE getAlbumType() {
Expand Down

0 comments on commit a50198c

Please sign in to comment.