Fixed deviantArt download link resolving

Turns out getURL works perfectly fine, but the Location header doesn't.
This commit is contained in:
Wiiplay123 2017-04-29 21:07:49 -05:00
parent 8f409eb28a
commit 624c28befa

View File

@ -363,7 +363,7 @@ public class DeviantartRipper extends AbstractHTMLRipper {
if (els.size() > 0) { if (els.size() > 0) {
// Full-size image // Full-size image
String downloadLink = els.get(0).attr("href"); String downloadLink = els.get(0).attr("href");
logger.info("Found download page: " + downloadLink); logger.info("Found download button link: " + downloadLink);
HttpURLConnection con = (HttpURLConnection) new URL(downloadLink).openConnection(); HttpURLConnection con = (HttpURLConnection) new URL(downloadLink).openConnection();
con.setRequestProperty("Referer",this.url.toString()); con.setRequestProperty("Referer",this.url.toString());
String cookieString = ""; String cookieString = "";
@ -376,10 +376,11 @@ public class DeviantartRipper extends AbstractHTMLRipper {
con.setInstanceFollowRedirects(true); con.setInstanceFollowRedirects(true);
con.connect(); con.connect();
int code = con.getResponseCode(); int code = con.getResponseCode();
String location = con.getHeaderField("Location"); String location = con.getURL().toString();
con.disconnect(); con.disconnect();
if (location.contains("//orig")) { if (location.contains("//orig")) {
fsimage = location; fsimage = location;
logger.info("Found image download: " + location);
} }
} }
if (fsimage != null) { if (fsimage != null) {