Added support for downloading embedded images from tumblrs

This commit is contained in:
cyian-1756 2018-09-22 23:43:01 -04:00
parent 6b8101533a
commit c489d86192

View File

@ -19,6 +19,9 @@ import com.rarchives.ripme.ripper.AlbumRipper;
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
import com.rarchives.ripme.utils.Http;
import com.rarchives.ripme.utils.Utils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
public class TumblrRipper extends AlbumRipper {
@ -235,7 +238,6 @@ public class TumblrRipper extends AlbumRipper {
for (int j = 0; j < photos.length(); j++) {
photo = photos.getJSONObject(j);
try {
// If the url is shorter than 65 chars long we skip it because it's those images don't support grabbing them in fullsize
fileURL = new URL(photo.getJSONObject("original_size").getString("url").replaceAll("http:", "https:"));
m = p.matcher(fileURL.toString());
@ -257,6 +259,16 @@ public class TumblrRipper extends AlbumRipper {
LOGGER.error("[!] Error while parsing video in " + post, e);
return true;
}
} else if (post.has("body")) {
Document d = Jsoup.parse(post.getString("body"));
if (!d.select("img").attr("src").isEmpty()) {
try {
addURLToDownload(new URL(d.select("img").attr("src")));
} catch (MalformedURLException e) {
LOGGER.error("[!] Error while getting embedded image at " + post, e);
return true;
}
}
}
if (albumType == ALBUM_TYPE.POST) {
return false;