mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-07 14:26:36 +02:00
new URI instead of new URL, deviantart, flickr.
This commit is contained in:
@@ -13,6 +13,8 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -381,11 +383,11 @@ public class DeviantartRipper extends AbstractHTMLRipper {
|
|||||||
try {
|
try {
|
||||||
String url = cleanURL();
|
String url = cleanURL();
|
||||||
if (this.usingCatPath) {
|
if (this.usingCatPath) {
|
||||||
return (new URL(url + "?catpath=/&offset=" + offset));
|
return (new URI(url + "?catpath=/&offset=" + offset)).toURL();
|
||||||
} else {
|
} else {
|
||||||
return (new URL(url + "?offset=" + offset));
|
return (new URI(url + "?offset=" + offset).toURL());
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -531,8 +533,6 @@ public class DeviantartRipper extends AbstractHTMLRipper {
|
|||||||
/**
|
/**
|
||||||
* Get URL to Artwork and return fullsize URL with file ending.
|
* 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
|
* @return URL like
|
||||||
* https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/intermediary/f/07f7a6bb-2d35-4630-93fc-be249af22b3e/d7jak0y-d20e5932-df72-4d13-b002-5e122037b373.jpg
|
* 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
|
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]);
|
title + "." + tmpParts[tmpParts.length - 1]);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -262,7 +262,7 @@ public class FlickrRipper extends AbstractHTMLRipper {
|
|||||||
JSONObject data = (JSONObject) pictures.get(i);
|
JSONObject data = (JSONObject) pictures.get(i);
|
||||||
try {
|
try {
|
||||||
addURLToDownload(getLargestImageURL(data.getString("id"), apiKey));
|
addURLToDownload(getLargestImageURL(data.getString("id"), apiKey));
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
LOGGER.error("Flickr MalformedURLException: " + e.getMessage());
|
LOGGER.error("Flickr MalformedURLException: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,11 +285,11 @@ public class FlickrRipper extends AbstractHTMLRipper {
|
|||||||
addURLToDownload(url, getPrefix(index));
|
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<>();
|
TreeMap<Integer, String> imageURLMap = new TreeMap<>();
|
||||||
|
|
||||||
try {
|
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");
|
JSONArray imageSizes = new JSONObject(Http.url(imageAPIURL).ignoreContentType().get().text()).getJSONObject("sizes").getJSONArray("size");
|
||||||
for (int i = 0; i < imageSizes.length(); i++) {
|
for (int i = 0; i < imageSizes.length(); i++) {
|
||||||
JSONObject imageInfo = imageSizes.getJSONObject(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());
|
LOGGER.error("IOException while looking at image sizes: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new URL(imageURLMap.lastEntry().getValue());
|
return new URI(imageURLMap.lastEntry().getValue()).toURL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user