1.1.9 - Hotfix for new imgur album format

This commit is contained in:
4pr0n 2015-09-17 02:04:57 -07:00
parent 4871142252
commit 9b09852aea
5 changed files with 10 additions and 10 deletions

View File

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

View File

@ -167,14 +167,14 @@ public class ImgurRipper extends AlbumRipper {
.get(); .get();
// Try to use embedded JSON to retrieve images // 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()); Matcher m = p.matcher(doc.body().html());
if (m.matches()) { if (m.matches()) {
try { try {
JSONObject json = new JSONObject(m.group(1)); JSONObject json = new JSONObject(m.group(1));
JSONObject jsonAlbum = json.getJSONObject("album"); JSONObject jsonAlbum = json.getJSONObject("album");
ImgurAlbum imgurAlbum = new ImgurAlbum(url, jsonAlbum.getString("title_clean")); 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(); int imagesLength = images.length();
for (int i = 0; i < imagesLength; i++) { for (int i = 0; i < imagesLength; i++) {
JSONObject image = images.getJSONObject(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); 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()); m = p.matcher(doc.body().html());
if (m.matches()) { if (m.matches()) {
try { try {
ImgurAlbum imgurAlbum = new ImgurAlbum(url); ImgurAlbum imgurAlbum = new ImgurAlbum(url);
JSONObject json = new JSONObject(m.group(1)); 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(); int imagesLength = images.length();
for (int i = 0; i < imagesLength; i++) { for (int i = 0; i < imagesLength; i++) {
JSONObject image = images.getJSONObject(i); JSONObject image = images.getJSONObject(i);
URL imageURL = new URL( URL imageURL = new URL(
"http:" + json.getString("cdnUrl") "http://i.imgur.com/"
+ "/"
+ image.getString("hash") + image.getString("hash")
+ image.getString("ext")); + image.getString("ext"));
ImgurImage imgurImage = new ImgurImage(imageURL); ImgurImage imgurImage = new ImgurImage(imageURL);

View File

@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils;
public class UpdateUtils { public class UpdateUtils {
private static final Logger logger = Logger.getLogger(UpdateUtils.class); 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 updateJsonURL = "http://rarchives.com/ripme.json";
private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String updateJarURL = "http://rarchives.com/ripme.jar";
private static final String mainFileName = "ripme.jar"; private static final String mainFileName = "ripme.jar";

View File

@ -33,7 +33,6 @@ public class ImgurRipperTest extends RippersTest {
public void testImgurAlbums() throws IOException { public void testImgurAlbums() throws IOException {
List<URL> contentURLs = new ArrayList<URL>(); List<URL> contentURLs = new ArrayList<URL>();
// URLs that should return more than 1 image // 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/dS9OQ#0")); // Horizontal layout
contentURLs.add(new URL("http://imgur.com/a/YpsW9#0")); // Grid 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")); contentURLs.add(new URL("http://imgur.com/a/WxG6f/layout/vertical#0"));

View File

@ -27,7 +27,7 @@ public class InstagramRipperTest extends RippersTest {
public void testInstagramAlbums() throws IOException { public void testInstagramAlbums() throws IOException {
List<URL> contentURLs = new ArrayList<URL>(); 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) { for (URL url : contentURLs) {
InstagramRipper ripper = new InstagramRipper(url); InstagramRipper ripper = new InstagramRipper(url);
testRipper(ripper); testRipper(ripper);