commit
39321a8b2c
@ -37,11 +37,8 @@ public class TumblrRipper extends AlbumRipper {
|
||||
private static final String TUMBLR_AUTH_CONFIG_KEY = "tumblr.auth";
|
||||
|
||||
private static boolean useDefaultApiKey = false; // fall-back for bad user-specified key
|
||||
private static final List<String> APIKEYS = Arrays.asList("JFNLu3CbINQjRdUvZibXW9VpSEVYYtiPJ86o8YmvgLZIoKyuNX",
|
||||
"FQrwZMCxVnzonv90rgNUJcAk4FpnoS0mYuSuGYqIpM2cFgp9L4",
|
||||
"qpdkY6nMknksfvYAhf2xIHp0iNRLkMlcWShxqzXyFJRxIsZ1Zz");
|
||||
private static int genNum = new Random().nextInt(APIKEYS.size());
|
||||
private static final String API_KEY = APIKEYS.get(genNum); // Select random API key from APIKEYS
|
||||
private static String API_KEY = null;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the API key.
|
||||
@ -49,6 +46,10 @@ public class TumblrRipper extends AlbumRipper {
|
||||
* @return Tumblr API key
|
||||
*/
|
||||
public static String getApiKey() {
|
||||
if (API_KEY == null) {
|
||||
API_KEY = pickRandomApiKey();
|
||||
}
|
||||
|
||||
if (useDefaultApiKey || Utils.getConfigString(TUMBLR_AUTH_CONFIG_KEY, "JFNLu3CbINQjRdUvZibXW9VpSEVYYtiPJ86o8YmvgLZIoKyuNX").equals("JFNLu3CbINQjRdUvZibXW9VpSEVYYtiPJ86o8YmvgLZIoKyuNX")) {
|
||||
logger.info("Using api key: " + API_KEY);
|
||||
return API_KEY;
|
||||
@ -60,9 +61,19 @@ public class TumblrRipper extends AlbumRipper {
|
||||
|
||||
}
|
||||
|
||||
private static String pickRandomApiKey() {
|
||||
final List<String> APIKEYS = Arrays.asList("JFNLu3CbINQjRdUvZibXW9VpSEVYYtiPJ86o8YmvgLZIoKyuNX",
|
||||
"FQrwZMCxVnzonv90rgNUJcAk4FpnoS0mYuSuGYqIpM2cFgp9L4",
|
||||
"qpdkY6nMknksfvYAhf2xIHp0iNRLkMlcWShxqzXyFJRxIsZ1Zz");
|
||||
int genNum = new Random().nextInt(APIKEYS.size());
|
||||
logger.info(genNum);
|
||||
final String API_KEY = APIKEYS.get(genNum); // Select random API key from APIKEYS
|
||||
return API_KEY;
|
||||
}
|
||||
|
||||
public TumblrRipper(URL url) throws IOException {
|
||||
super(url);
|
||||
if (API_KEY == null) {
|
||||
if (getApiKey() == null) {
|
||||
throw new IOException("Could not find tumblr authentication key in configuration");
|
||||
}
|
||||
}
|
||||
@ -245,7 +256,7 @@ public class TumblrRipper extends AlbumRipper {
|
||||
}
|
||||
} else if (post.has("video_url")) {
|
||||
try {
|
||||
fileURL = new URL(post.getString("video_url").replaceAll("http", "https"));
|
||||
fileURL = new URL(post.getString("video_url").replaceAll("http:", "https:"));
|
||||
addURLToDownload(fileURL);
|
||||
} catch (Exception e) {
|
||||
logger.error("[!] Error while parsing video in " + post, e);
|
||||
|
Loading…
Reference in New Issue
Block a user