1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-04-22 04:32:06 +02:00

new URI instead of new URL, deviantart, flickr.

This commit is contained in:
soloturn 2023-12-29 11:49:08 +01:00
parent e5c367df44
commit 7afe1eb7d9
2 changed files with 11 additions and 11 deletions

View File

@ -13,6 +13,8 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@ -381,11 +383,11 @@ public class DeviantartRipper extends AbstractHTMLRipper {
try {
String url = cleanURL();
if (this.usingCatPath) {
return (new URL(url + "?catpath=/&offset=" + offset));
return (new URI(url + "?catpath=/&offset=" + offset)).toURL();
} else {
return (new URL(url + "?offset=" + offset));
return (new URI(url + "?offset=" + offset).toURL());
}
} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
e.printStackTrace();
}
return null;
@ -531,8 +533,6 @@ public class DeviantartRipper extends AbstractHTMLRipper {
/**
* Get URL to Artwork and return fullsize URL with file ending.
*
* @param page Like
* https://www.deviantart.com/apofiss/art/warmest-of-the-days-455668450
* @return URL like
* https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/intermediary/f/07f7a6bb-2d35-4630-93fc-be249af22b3e/d7jak0y-d20e5932-df72-4d13-b002-5e122037b373.jpg
*
@ -628,11 +628,11 @@ public class DeviantartRipper extends AbstractHTMLRipper {
}
String[] tmpParts = downloadString.split("\\."); //split to get file ending
addURLToDownload(new URL(downloadString), "", "", "", new HashMap<String, String>(),
addURLToDownload(new URI(downloadString).toURL(), "", "", "", new HashMap<String, String>(),
title + "." + tmpParts[tmpParts.length - 1]);
return;
} catch (IOException e) {
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}

View File

@ -262,7 +262,7 @@ public class FlickrRipper extends AbstractHTMLRipper {
JSONObject data = (JSONObject) pictures.get(i);
try {
addURLToDownload(getLargestImageURL(data.getString("id"), apiKey));
} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
LOGGER.error("Flickr MalformedURLException: " + e.getMessage());
}
@ -285,11 +285,11 @@ public class FlickrRipper extends AbstractHTMLRipper {
addURLToDownload(url, getPrefix(index));
}
private URL getLargestImageURL(String imageID, String apiKey) throws MalformedURLException {
private URL getLargestImageURL(String imageID, String apiKey) throws MalformedURLException, URISyntaxException {
TreeMap<Integer, String> imageURLMap = new TreeMap<>();
try {
URL imageAPIURL = new URL("https://www.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=" + apiKey + "&photo_id=" + imageID + "&format=json&nojsoncallback=1");
URL imageAPIURL = new URI("https://www.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=" + apiKey + "&photo_id=" + imageID + "&format=json&nojsoncallback=1").toURL();
JSONArray imageSizes = new JSONObject(Http.url(imageAPIURL).ignoreContentType().get().text()).getJSONObject("sizes").getJSONArray("size");
for (int i = 0; i < imageSizes.length(); i++) {
JSONObject imageInfo = imageSizes.getJSONObject(i);
@ -304,6 +304,6 @@ public class FlickrRipper extends AbstractHTMLRipper {
LOGGER.error("IOException while looking at image sizes: " + e.getMessage());
}
return new URL(imageURLMap.lastEntry().getValue());
return new URI(imageURLMap.lastEntry().getValue()).toURL();
}
}