1.0.16 - Fixed bug for Instagram usernames with - and _ #7

This commit is contained in:
4pr0n 2014-04-10 23:19:21 -07:00
parent abdf7a504c
commit a1dd9bbd25
3 changed files with 18 additions and 4 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.rarchives.ripme</groupId>
<artifactId>ripme</artifactId>
<packaging>jar</packaging>
<version>1.0.15</version>
<version>1.0.16</version>
<name>ripme</name>
<url>http://rip.rarchives.com</url>
<properties>

View File

@ -32,7 +32,7 @@ public class InstagramRipper extends AbstractRipper {
@Override
public URL sanitizeURL(URL url) throws MalformedURLException {
Pattern p = Pattern.compile("^https?://instagram\\.com/p/([a-zA-Z0-9]{1,}).*$");
Pattern p = Pattern.compile("^https?://instagram\\.com/p/([a-zA-Z0-9\\-_]{1,}).*$");
Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) {
// Link to photo, not the user account
@ -43,7 +43,7 @@ public class InstagramRipper extends AbstractRipper {
throw new MalformedURLException("Failed to retrieve user page from " + url);
}
}
p = Pattern.compile("^.*instagram.com/([a-zA-Z0-9]{3,}).*$");
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);
@ -132,7 +132,7 @@ public class InstagramRipper extends AbstractRipper {
@Override
public String getGID(URL url) throws MalformedURLException {
Pattern p = Pattern.compile("^https?://statigr.am/([a-zA-Z0-9]{3,}).*$");
Pattern p = Pattern.compile("^https?://statigr.am/([a-zA-Z0-9\\-_]{3,}).*$");
Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) {
return m.group(1);

View File

@ -3,12 +3,26 @@ package com.rarchives.ripme.tst.ripper.rippers;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.rarchives.ripme.ripper.rippers.InstagramRipper;
public class InstagramRipperTest extends RippersTest {
public void testInstagramGID() throws IOException {
Map<URL, String> testURLs = new HashMap<URL, String>();
testURLs.put(new URL("http://instagram.com/Test_User"), "Test_User");
testURLs.put(new URL("http://instagram.com/_test_user_"), "_test_user_");
testURLs.put(new URL("http://instagram.com/-test-user-"), "-test-user-");
for (URL url : testURLs.keySet()) {
InstagramRipper ripper = new InstagramRipper(url);
assertEquals(testURLs.get(url), ripper.getGID(ripper.getURL()));
deleteDir(ripper.getWorkingDir());
}
}
public void testInstagramAlbums() throws IOException {
if (!DOWNLOAD_CONTENT) {
return;