mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-06 13:56:34 +02:00
Imgur ripper now use api.imgur.com when ripping albums to bypass age gate
This commit is contained in:
@@ -15,6 +15,7 @@ import org.json.JSONObject;
|
|||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.jsoup.safety.Whitelist;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AlbumRipper;
|
import com.rarchives.ripme.ripper.AlbumRipper;
|
||||||
@@ -272,20 +273,17 @@ public class ImgurRipper extends AlbumRipper {
|
|||||||
strUrl += "/all";
|
strUrl += "/all";
|
||||||
}
|
}
|
||||||
LOGGER.info(" Retrieving " + strUrl);
|
LOGGER.info(" Retrieving " + strUrl);
|
||||||
Document doc = getDocument(strUrl);
|
Document doc = getAlbumData("https://api.imgur.com/3/album/" + strUrl.split("/a/")[1]);
|
||||||
// Try to use embedded JSON to retrieve images
|
// Try to use embedded JSON to retrieve images
|
||||||
Matcher m = getEmbeddedJsonMatcher(doc);
|
LOGGER.info(Jsoup.clean(doc.body().toString(), Whitelist.none()));
|
||||||
if (m.matches()) {
|
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject(m.group(1));
|
JSONObject json = new JSONObject(Jsoup.clean(doc.body().toString(), Whitelist.none()));
|
||||||
JSONArray jsonImages = json.getJSONObject("image")
|
JSONArray jsonImages = json.getJSONObject("data").getJSONArray("images");
|
||||||
.getJSONObject("album_images")
|
|
||||||
.getJSONArray("images");
|
|
||||||
return createImgurAlbumFromJsonArray(url, jsonImages);
|
return createImgurAlbumFromJsonArray(url, jsonImages);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
LOGGER.debug("Error while parsing JSON at " + url + ", continuing", e);
|
LOGGER.debug("Error while parsing JSON at " + url + ", continuing", e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// TODO If album is empty, use this to check for cached images:
|
// TODO If album is empty, use this to check for cached images:
|
||||||
// http://i.rarchives.com/search.cgi?cache=http://imgur.com/a/albumID
|
// http://i.rarchives.com/search.cgi?cache=http://imgur.com/a/albumID
|
||||||
@@ -332,8 +330,8 @@ public class ImgurRipper extends AlbumRipper {
|
|||||||
ImgurAlbum imgurAlbum = new ImgurAlbum(url);
|
ImgurAlbum imgurAlbum = new ImgurAlbum(url);
|
||||||
int imagesLength = jsonImages.length();
|
int imagesLength = jsonImages.length();
|
||||||
for (int i = 0; i < imagesLength; i++) {
|
for (int i = 0; i < imagesLength; i++) {
|
||||||
JSONObject jsonImage = jsonImages.getJSONObject(i);
|
JSONObject ob = jsonImages.getJSONObject(i);
|
||||||
imgurAlbum.addImage(createImgurImageFromJson(jsonImage));
|
imgurAlbum.addImage(new ImgurImage( new URL(ob.getString("link"))));
|
||||||
}
|
}
|
||||||
return imgurAlbum;
|
return imgurAlbum;
|
||||||
}
|
}
|
||||||
@@ -361,6 +359,17 @@ public class ImgurRipper extends AlbumRipper {
|
|||||||
.get();
|
.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Document getAlbumData(String strUrl) throws IOException {
|
||||||
|
return Jsoup.connect(strUrl)
|
||||||
|
.userAgent(USER_AGENT)
|
||||||
|
.timeout(10 * 1000)
|
||||||
|
.maxBodySize(0)
|
||||||
|
.header("Authorization", "Client-ID 546c25a59c58ad7")
|
||||||
|
.ignoreContentType(true)
|
||||||
|
.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rips all albums in an imgur user's account.
|
* Rips all albums in an imgur user's account.
|
||||||
* @param url
|
* @param url
|
||||||
|
Reference in New Issue
Block a user