mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-10 16:04:19 +02:00
Retry sleep time
This commit is contained in:
@@ -97,6 +97,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private static JLabel configSaveDirLabel;
|
private static JLabel configSaveDirLabel;
|
||||||
private static JButton configSaveDirButton;
|
private static JButton configSaveDirButton;
|
||||||
private static JTextField configRetriesText;
|
private static JTextField configRetriesText;
|
||||||
|
private JTextField configRetrySleepText;
|
||||||
private static JCheckBox configAutoupdateCheckbox;
|
private static JCheckBox configAutoupdateCheckbox;
|
||||||
private static JComboBox<String> configLogLevelCombobox;
|
private static JComboBox<String> configLogLevelCombobox;
|
||||||
private static JCheckBox configURLHistoryCheckbox;
|
private static JCheckBox configURLHistoryCheckbox;
|
||||||
@@ -114,6 +115,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private static JLabel configThreadsLabel;
|
private static JLabel configThreadsLabel;
|
||||||
private static JLabel configTimeoutLabel;
|
private static JLabel configTimeoutLabel;
|
||||||
private static JLabel configRetriesLabel;
|
private static JLabel configRetriesLabel;
|
||||||
|
private static JLabel configRetrySleepLabel;
|
||||||
// This doesn't really belong here but I have no idea where else to put it
|
// This doesn't really belong here but I have no idea where else to put it
|
||||||
private static JButton configUrlFileChooserButton;
|
private static JButton configUrlFileChooserButton;
|
||||||
|
|
||||||
@@ -502,9 +504,12 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configThreadsLabel = new JLabel(Utils.getLocalizedString("max.download.threads") + ":", JLabel.RIGHT);
|
configThreadsLabel = new JLabel(Utils.getLocalizedString("max.download.threads") + ":", JLabel.RIGHT);
|
||||||
configTimeoutLabel = new JLabel(Utils.getLocalizedString("timeout.mill"), JLabel.RIGHT);
|
configTimeoutLabel = new JLabel(Utils.getLocalizedString("timeout.mill"), JLabel.RIGHT);
|
||||||
configRetriesLabel = new JLabel(Utils.getLocalizedString("retry.download.count"), JLabel.RIGHT);
|
configRetriesLabel = new JLabel(Utils.getLocalizedString("retry.download.count"), JLabel.RIGHT);
|
||||||
|
configRetrySleepLabel = new JLabel(Utils.getLocalizedString("retry.sleep.mill"), JLabel.RIGHT);
|
||||||
configThreadsText = configField("threads.size", 3);
|
configThreadsText = configField("threads.size", 3);
|
||||||
configTimeoutText = configField("download.timeout", 60000);
|
configTimeoutText = configField("download.timeout", 60000);
|
||||||
configRetriesText = configField("download.retries", 3);
|
configRetriesText = configField("download.retries", 3);
|
||||||
|
configRetrySleepText = configField("download.retry.sleep", 5000);
|
||||||
|
|
||||||
configOverwriteCheckbox = addNewCheckbox(Utils.getLocalizedString("overwrite.existing.files"), "file.overwrite",
|
configOverwriteCheckbox = addNewCheckbox(Utils.getLocalizedString("overwrite.existing.files"), "file.overwrite",
|
||||||
false);
|
false);
|
||||||
configAutoupdateCheckbox = addNewCheckbox(Utils.getLocalizedString("auto.update"), "auto.update", true);
|
configAutoupdateCheckbox = addNewCheckbox(Utils.getLocalizedString("auto.update"), "auto.update", true);
|
||||||
@@ -547,19 +552,21 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT);
|
configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT);
|
||||||
configSaveDirButton = new JButton(Utils.getLocalizedString("select.save.dir") + "...");
|
configSaveDirButton = new JButton(Utils.getLocalizedString("select.save.dir") + "...");
|
||||||
|
|
||||||
addItemToConfigGridBagConstraints(gbc, 0, configUpdateLabel, configUpdateButton);
|
var idx = 0;
|
||||||
addItemToConfigGridBagConstraints(gbc, 1, configAutoupdateCheckbox, configLogLevelCombobox);
|
addItemToConfigGridBagConstraints(gbc, idx++, configUpdateLabel, configUpdateButton);
|
||||||
addItemToConfigGridBagConstraints(gbc, 2, configThreadsLabel, configThreadsText);
|
addItemToConfigGridBagConstraints(gbc, idx++, configAutoupdateCheckbox, configLogLevelCombobox);
|
||||||
addItemToConfigGridBagConstraints(gbc, 3, configTimeoutLabel, configTimeoutText);
|
addItemToConfigGridBagConstraints(gbc, idx++, configThreadsLabel, configThreadsText);
|
||||||
addItemToConfigGridBagConstraints(gbc, 4, configRetriesLabel, configRetriesText);
|
addItemToConfigGridBagConstraints(gbc, idx++, configTimeoutLabel, configTimeoutText);
|
||||||
addItemToConfigGridBagConstraints(gbc, 5, configOverwriteCheckbox, configSaveOrderCheckbox);
|
addItemToConfigGridBagConstraints(gbc, idx++, configRetriesLabel, configRetriesText);
|
||||||
addItemToConfigGridBagConstraints(gbc, 6, configPlaySound, configSaveLogs);
|
addItemToConfigGridBagConstraints(gbc, idx++, configRetrySleepLabel, configRetrySleepText);
|
||||||
addItemToConfigGridBagConstraints(gbc, 7, configShowPopup, configSaveURLsOnly);
|
addItemToConfigGridBagConstraints(gbc, idx++, configOverwriteCheckbox, configSaveOrderCheckbox);
|
||||||
addItemToConfigGridBagConstraints(gbc, 8, configClipboardAutorip, configSaveAlbumTitles);
|
addItemToConfigGridBagConstraints(gbc, idx++, configPlaySound, configSaveLogs);
|
||||||
addItemToConfigGridBagConstraints(gbc, 9, configSaveDescriptions, configPreferMp4);
|
addItemToConfigGridBagConstraints(gbc, idx++, configShowPopup, configSaveURLsOnly);
|
||||||
addItemToConfigGridBagConstraints(gbc, 10, configWindowPosition, configURLHistoryCheckbox);
|
addItemToConfigGridBagConstraints(gbc, idx++, configClipboardAutorip, configSaveAlbumTitles);
|
||||||
addItemToConfigGridBagConstraints(gbc, 11, configSelectLangComboBox, configUrlFileChooserButton);
|
addItemToConfigGridBagConstraints(gbc, idx++, configSaveDescriptions, configPreferMp4);
|
||||||
addItemToConfigGridBagConstraints(gbc, 12, configSaveDirLabel, configSaveDirButton);
|
addItemToConfigGridBagConstraints(gbc, idx++, configWindowPosition, configURLHistoryCheckbox);
|
||||||
|
addItemToConfigGridBagConstraints(gbc, idx++, configSelectLangComboBox, configUrlFileChooserButton);
|
||||||
|
addItemToConfigGridBagConstraints(gbc, idx++, configSaveDirLabel, configSaveDirButton);
|
||||||
|
|
||||||
emptyPanel = new JPanel();
|
emptyPanel = new JPanel();
|
||||||
emptyPanel.setPreferredSize(new Dimension(0, 0));
|
emptyPanel.setPreferredSize(new Dimension(0, 0));
|
||||||
|
@@ -30,6 +30,7 @@ public class Http {
|
|||||||
private static final Logger logger = LogManager.getLogger(Http.class);
|
private static final Logger logger = LogManager.getLogger(Http.class);
|
||||||
|
|
||||||
private int retries;
|
private int retries;
|
||||||
|
private int retrySleep = 0;
|
||||||
private final String url;
|
private final String url;
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ public class Http {
|
|||||||
|
|
||||||
private void defaultSettings() {
|
private void defaultSettings() {
|
||||||
this.retries = Utils.getConfigInteger("download.retries", 1);
|
this.retries = Utils.getConfigInteger("download.retries", 1);
|
||||||
|
this.retrySleep = Utils.getConfigInteger("download.retry.sleep", 5000);
|
||||||
connection = Jsoup.connect(this.url);
|
connection = Jsoup.connect(this.url);
|
||||||
connection.userAgent(AbstractRipper.USER_AGENT);
|
connection.userAgent(AbstractRipper.USER_AGENT);
|
||||||
connection.method(Method.GET);
|
connection.method(Method.GET);
|
||||||
@@ -210,9 +212,21 @@ public class Http {
|
|||||||
if (status == 401 || status == 403) {
|
if (status == 401 || status == 403) {
|
||||||
throw new IOException("Failed to load " + url + ": Status Code " + status + ". You might be able to circumvent this error by setting cookies for this domain", e);
|
throw new IOException("Failed to load " + url + ": Status Code " + status + ". You might be able to circumvent this error by setting cookies for this domain", e);
|
||||||
}
|
}
|
||||||
|
if (status == 404) {
|
||||||
|
throw new IOException("File not found " + url + ": Status Code " + status + ". ", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn("Error while loading " + url, e);
|
if (retrySleep > 0 && retries >= 0) {
|
||||||
|
try {
|
||||||
|
logger.warn("Error while loading " + url + " waiting "+ retrySleep + " ms before retrying.", e);
|
||||||
|
Thread.sleep(retrySleep);
|
||||||
|
} catch (final InterruptedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn("Error while loading " + url, e);
|
||||||
|
}
|
||||||
lastException = e;
|
lastException = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@ auto.update = Auto-update?
|
|||||||
max.download.threads = Maximum download threads:
|
max.download.threads = Maximum download threads:
|
||||||
timeout.mill = Timeout (in milliseconds):
|
timeout.mill = Timeout (in milliseconds):
|
||||||
retry.download.count = Retry download count
|
retry.download.count = Retry download count
|
||||||
|
retry.sleep.mill = Wait between retries (in milliseconds):
|
||||||
overwrite.existing.files = Overwrite existing files?
|
overwrite.existing.files = Overwrite existing files?
|
||||||
sound.when.rip.completes = Sound when rip completes
|
sound.when.rip.completes = Sound when rip completes
|
||||||
preserve.order = Preserve order
|
preserve.order = Preserve order
|
||||||
|
Reference in New Issue
Block a user