mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-14 01:44:12 +02:00
new URI instead of new URL, tumblr.
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
package com.rarchives.ripme.ripper.rippers;
|
package com.rarchives.ripme.ripper.rippers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.*;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@@ -100,11 +98,11 @@ public class TumblrRipper extends AlbumRipper {
|
|||||||
* @throws MalformedURLException
|
* @throws MalformedURLException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
|
||||||
String u = url.toExternalForm();
|
String u = url.toExternalForm();
|
||||||
// Convert <FQDN>.tumblr.com/path to <FQDN>/path if needed
|
// Convert <FQDN>.tumblr.com/path to <FQDN>/path if needed
|
||||||
if (StringUtils.countMatches(u, ".") > 2) {
|
if (StringUtils.countMatches(u, ".") > 2) {
|
||||||
url = new URL(u.replace(".tumblr.com", ""));
|
url = new URI(u.replace(".tumblr.com", "")).toURL();
|
||||||
if (isTumblrURL(url)) {
|
if (isTumblrURL(url)) {
|
||||||
LOGGER.info("Detected tumblr site: " + url);
|
LOGGER.info("Detected tumblr site: " + url);
|
||||||
}
|
}
|
||||||
@@ -263,7 +261,7 @@ public class TumblrRipper extends AlbumRipper {
|
|||||||
fileLocation = photo.getJSONObject("original_size").getString("url").replaceAll("http:", "https:");
|
fileLocation = photo.getJSONObject("original_size").getString("url").replaceAll("http:", "https:");
|
||||||
qualM = qualP.matcher(fileLocation);
|
qualM = qualP.matcher(fileLocation);
|
||||||
fileLocation = qualM.replaceFirst("_1280.$1");
|
fileLocation = qualM.replaceFirst("_1280.$1");
|
||||||
fileURL = new URL(fileLocation);
|
fileURL = new URI(fileLocation).toURL();
|
||||||
|
|
||||||
m = p.matcher(fileURL.toString());
|
m = p.matcher(fileURL.toString());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
@@ -278,7 +276,7 @@ public class TumblrRipper extends AlbumRipper {
|
|||||||
}
|
}
|
||||||
} else if (post.has("video_url")) {
|
} else if (post.has("video_url")) {
|
||||||
try {
|
try {
|
||||||
fileURL = new URL(post.getString("video_url").replaceAll("http:", "https:"));
|
fileURL = new URI(post.getString("video_url").replaceAll("http:", "https:")).toURL();
|
||||||
downloadURL(fileURL, date);
|
downloadURL(fileURL, date);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("[!] Error while parsing video in " + post, e);
|
LOGGER.error("[!] Error while parsing video in " + post, e);
|
||||||
@@ -293,8 +291,8 @@ public class TumblrRipper extends AlbumRipper {
|
|||||||
// If the image is any smaller, it will still get the largest available size
|
// If the image is any smaller, it will still get the largest available size
|
||||||
qualM = qualP.matcher(imgSrc);
|
qualM = qualP.matcher(imgSrc);
|
||||||
imgSrc = qualM.replaceFirst("_1280.$1");
|
imgSrc = qualM.replaceFirst("_1280.$1");
|
||||||
downloadURL(new URL(imgSrc), date);
|
downloadURL(new URI(imgSrc).toURL(), date);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
LOGGER.error("[!] Error while getting embedded image at " + post, e);
|
LOGGER.error("[!] Error while getting embedded image at " + post, e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user