1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-15 10:24:04 +02:00

Fix imgur url scheme and remove json from logs

This commit is contained in:
Tush-r
2024-09-12 16:46:46 +05:30
committed by soloturn
parent d439ff0b3e
commit e7a531b8b6

View File

@@ -255,8 +255,6 @@ public class ImgurRipper extends AbstractHTMLRipper {
LOGGER.info(" Retrieving " + strUrl); LOGGER.info(" Retrieving " + strUrl);
Document doc = getAlbumData("https://api.imgur.com/3/album/" + strUrl.split("/a/")[1]); 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
LOGGER.info(Jsoup.clean(doc.body().toString(), Safelist.none()));
try { try {
JSONObject json = new JSONObject(Jsoup.clean(doc.body().toString(), Safelist.none())); JSONObject json = new JSONObject(Jsoup.clean(doc.body().toString(), Safelist.none()));
JSONArray jsonImages = json.getJSONObject("data").getJSONArray("images"); JSONArray jsonImages = json.getJSONObject("data").getJSONArray("images");
@@ -427,7 +425,7 @@ public class ImgurRipper extends AbstractHTMLRipper {
for (int i = 0; i < images.length(); i++) { for (int i = 0; i < images.length(); i++) {
imagesFound++; imagesFound++;
JSONObject image = images.getJSONObject(i); JSONObject image = images.getJSONObject(i);
String imageUrl = "http://i.imgur.com/" + image.getString("hash") + image.getString("ext"); String imageUrl = "https://i.imgur.com/" + image.getString("hash") + image.getString("ext");
String prefix = ""; String prefix = "";
if (Utils.getConfigBoolean("download.save_order", true)) { if (Utils.getConfigBoolean("download.save_order", true)) {
prefix = String.format("%03d_", imagesFound); prefix = String.format("%03d_", imagesFound);
@@ -497,7 +495,7 @@ public class ImgurRipper extends AbstractHTMLRipper {
// Imgur album or gallery // Imgur album or gallery
albumType = ALBUM_TYPE.ALBUM; albumType = ALBUM_TYPE.ALBUM;
String gid = m.group(m.groupCount()); String gid = m.group(m.groupCount());
this.url = new URI("http://imgur.com/a/" + gid).toURL(); this.url = new URI("https://imgur.com/a/" + gid).toURL();
return gid; return gid;
} }
// Match urls with path /a // Match urls with path /a
@@ -507,7 +505,7 @@ public class ImgurRipper extends AbstractHTMLRipper {
// Imgur album or gallery // Imgur album or gallery
albumType = ALBUM_TYPE.ALBUM; albumType = ALBUM_TYPE.ALBUM;
String gid = m.group(m.groupCount()); String gid = m.group(m.groupCount());
this.url = new URI("http://imgur.com/a/" + gid).toURL(); this.url = new URI("https://imgur.com/a/" + gid).toURL();
return gid; return gid;
} }
p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{4,})\\.imgur\\.com/?$"); p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{4,})\\.imgur\\.com/?$");
@@ -563,7 +561,7 @@ public class ImgurRipper extends AbstractHTMLRipper {
albumType = ALBUM_TYPE.ALBUM; albumType = ALBUM_TYPE.ALBUM;
String subreddit = m.group(m.groupCount() - 1); String subreddit = m.group(m.groupCount() - 1);
String gid = m.group(m.groupCount()); String gid = m.group(m.groupCount());
this.url = new URI("http://imgur.com/r/" + subreddit + "/" + gid).toURL(); this.url = new URI("https://imgur.com/r/" + subreddit + "/" + gid).toURL();
return "r_" + subreddit + "_" + gid; return "r_" + subreddit + "_" + gid;
} }
p = Pattern.compile("^https?://(i\\.|www\\.|m\\.)?imgur\\.com/([a-zA-Z0-9]{5,})$"); p = Pattern.compile("^https?://(i\\.|www\\.|m\\.)?imgur\\.com/([a-zA-Z0-9]{5,})$");