[tumblr] avoid 'httpss' in image URLs

fixes #523

replacing 'http' with 'https' in an URL already starting with
'https://...' changes its scheme/protocol to 'httpss'
This commit is contained in:
Mike Fährmann 2018-04-19 15:14:24 +02:00
parent 1bc696504a
commit 034225cf1c
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -44,7 +44,7 @@ public class TumblrRipper extends AlbumRipper {
private static final String API_KEY = APIKEYS.get(genNum); // Select random API key from APIKEYS private static final String API_KEY = APIKEYS.get(genNum); // Select random API key from APIKEYS
/** /**
* Gets the API key. * Gets the API key.
* Chooses between default/included keys & user specified ones (from the config file). * Chooses between default/included keys & user specified ones (from the config file).
* @return Tumblr API key * @return Tumblr API key
*/ */
@ -57,7 +57,7 @@ public class TumblrRipper extends AlbumRipper {
logger.info("Using user tumblr.auth api key: " + userDefinedAPIKey); logger.info("Using user tumblr.auth api key: " + userDefinedAPIKey);
return userDefinedAPIKey; return userDefinedAPIKey;
} }
} }
public TumblrRipper(URL url) throws IOException { public TumblrRipper(URL url) throws IOException {
@ -71,12 +71,12 @@ public class TumblrRipper extends AlbumRipper {
public boolean canRip(URL url) { public boolean canRip(URL url) {
return url.getHost().endsWith(DOMAIN); return url.getHost().endsWith(DOMAIN);
} }
/** /**
* Sanitizes URL. * Sanitizes URL.
* @param url URL to be sanitized. * @param url URL to be sanitized.
* @return Sanitized URL * @return Sanitized URL
* @throws MalformedURLException * @throws MalformedURLException
*/ */
@Override @Override
public URL sanitizeURL(URL url) throws MalformedURLException { public URL sanitizeURL(URL url) throws MalformedURLException {
@ -230,7 +230,7 @@ public class TumblrRipper extends AlbumRipper {
urlString = urlString.replaceAll("_\\d+\\.", "_raw."); urlString = urlString.replaceAll("_\\d+\\.", "_raw.");
fileURL = new URL(urlString); fileURL = new URL(urlString);
} else { } else {
fileURL = new URL(photo.getJSONObject("original_size").getString("url").replaceAll("http", "https")); fileURL = new URL(photo.getJSONObject("original_size").getString("url").replaceAll("http:", "https:"));
} }
m = p.matcher(fileURL.toString()); m = p.matcher(fileURL.toString());
if (m.matches()) { if (m.matches()) {