1.1.9 - Hotfix for new imgur album format
This commit is contained in:
parent
4871142252
commit
9b09852aea
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<groupId>com.rarchives.ripme</groupId>
|
||||
<artifactId>ripme</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.1.8</version>
|
||||
<version>1.1.9</version>
|
||||
<name>ripme</name>
|
||||
<url>http://rip.rarchives.com</url>
|
||||
<properties>
|
||||
|
@ -167,14 +167,14 @@ public class ImgurRipper extends AlbumRipper {
|
||||
.get();
|
||||
|
||||
// Try to use embedded JSON to retrieve images
|
||||
Pattern p = Pattern.compile("^.*Imgur\\.Album\\.getInstance\\((.*)\\);.*$", Pattern.DOTALL);
|
||||
Pattern p = Pattern.compile("^.*Imgur\\.Album\\.getInstance\\((.*?)\\);.*$", Pattern.DOTALL);
|
||||
Matcher m = p.matcher(doc.body().html());
|
||||
if (m.matches()) {
|
||||
try {
|
||||
JSONObject json = new JSONObject(m.group(1));
|
||||
JSONObject jsonAlbum = json.getJSONObject("album");
|
||||
ImgurAlbum imgurAlbum = new ImgurAlbum(url, jsonAlbum.getString("title_clean"));
|
||||
JSONArray images = json.getJSONObject("images").getJSONArray("items");
|
||||
JSONArray images = json.getJSONObject("images").getJSONArray("images");
|
||||
int imagesLength = images.length();
|
||||
for (int i = 0; i < imagesLength; i++) {
|
||||
JSONObject image = images.getJSONObject(i);
|
||||
@ -193,19 +193,20 @@ public class ImgurRipper extends AlbumRipper {
|
||||
logger.debug("Error while parsing JSON at " + url + ", continuing", e);
|
||||
}
|
||||
}
|
||||
p = Pattern.compile("^.*= new ImgurShare\\((.*)\\);.*$", Pattern.DOTALL);
|
||||
p = Pattern.compile("^.*widgetFactory.mergeConfig\\('gallery', (.*?)\\);.*$", Pattern.DOTALL);
|
||||
m = p.matcher(doc.body().html());
|
||||
if (m.matches()) {
|
||||
try {
|
||||
ImgurAlbum imgurAlbum = new ImgurAlbum(url);
|
||||
JSONObject json = new JSONObject(m.group(1));
|
||||
JSONArray images = json.getJSONArray("hashes");
|
||||
JSONArray images = json.getJSONObject("image")
|
||||
.getJSONObject("album_images")
|
||||
.getJSONArray("images");
|
||||
int imagesLength = images.length();
|
||||
for (int i = 0; i < imagesLength; i++) {
|
||||
JSONObject image = images.getJSONObject(i);
|
||||
URL imageURL = new URL(
|
||||
"http:" + json.getString("cdnUrl")
|
||||
+ "/"
|
||||
"http://i.imgur.com/"
|
||||
+ image.getString("hash")
|
||||
+ image.getString("ext"));
|
||||
ImgurImage imgurImage = new ImgurImage(imageURL);
|
||||
|
@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils;
|
||||
public class UpdateUtils {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(UpdateUtils.class);
|
||||
private static final String DEFAULT_VERSION = "1.1.8";
|
||||
private static final String DEFAULT_VERSION = "1.1.9";
|
||||
private static final String updateJsonURL = "http://rarchives.com/ripme.json";
|
||||
private static final String updateJarURL = "http://rarchives.com/ripme.jar";
|
||||
private static final String mainFileName = "ripme.jar";
|
||||
|
@ -33,7 +33,6 @@ public class ImgurRipperTest extends RippersTest {
|
||||
public void testImgurAlbums() throws IOException {
|
||||
List<URL> contentURLs = new ArrayList<URL>();
|
||||
// URLs that should return more than 1 image
|
||||
contentURLs.add(new URL("http://imgur.com/a/hqJIu")); // Vertical layout
|
||||
contentURLs.add(new URL("http://imgur.com/a/dS9OQ#0")); // Horizontal layout
|
||||
contentURLs.add(new URL("http://imgur.com/a/YpsW9#0")); // Grid layout
|
||||
contentURLs.add(new URL("http://imgur.com/a/WxG6f/layout/vertical#0"));
|
||||
|
@ -27,7 +27,7 @@ public class InstagramRipperTest extends RippersTest {
|
||||
|
||||
public void testInstagramAlbums() throws IOException {
|
||||
List<URL> contentURLs = new ArrayList<URL>();
|
||||
contentURLs.add(new URL("http://instagram.com/tayloralesia/"));
|
||||
contentURLs.add(new URL("http://instagram.com/anacheri"));
|
||||
for (URL url : contentURLs) {
|
||||
InstagramRipper ripper = new InstagramRipper(url);
|
||||
testRipper(ripper);
|
||||
|
Loading…
Reference in New Issue
Block a user