From 9ccbc8ac094b3a327d99ede8feff3ef3280ec18b Mon Sep 17 00:00:00 2001 From: 4pr0n Date: Mon, 21 Apr 2014 23:03:40 -0700 Subject: [PATCH] Handle statigr.am URLs (for re-ripping) --- .../ripme/ripper/rippers/InstagramRipper.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java index 3f39fd4f..e82bc58c 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java @@ -27,7 +27,8 @@ public class InstagramRipper extends AlbumRipper { @Override public boolean canRip(URL url) { - return url.getHost().endsWith(DOMAIN); + return (url.getHost().endsWith(DOMAIN) + || url.getHost().endsWith("statigr.am")); } @Override @@ -45,10 +46,15 @@ public class InstagramRipper extends AlbumRipper { } p = Pattern.compile("^.*instagram.com/([a-zA-Z0-9\\-_]{3,}).*$"); m = p.matcher(url.toExternalForm()); - if (!m.matches()) { - throw new MalformedURLException("Expected username in URL (instagram.com/username and not " + url); + if (m.matches()) { + return new URL("http://statigr.am/" + m.group(1)); } - return new URL("http://statigr.am/" + m.group(1)); + p = Pattern.compile("^.*statigr.am/([a-zA-Z0-9\\-_]{3,}).*$"); + m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return new URL("http://statigr.am/" + m.group(1)); + } + throw new MalformedURLException("Expected username in URL (instagram.com/username and not " + url); } private URL getUserPageFromImage(URL url) throws IOException {