Option to only save URLs to images, not download

This commit is contained in:
4pr0n 2014-06-28 09:47:46 -07:00
parent baab27d6af
commit 97506c8741
3 changed files with 49 additions and 9 deletions

View File

@ -1,5 +1,6 @@
package com.rarchives.ripme.ripper;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
@ -208,7 +209,7 @@ public abstract class AbstractRipper
if (!completed) {
completed = true;
logger.info(" Rip completed!");
RipStatusMessage msg = new RipStatusMessage(STATUS.RIP_COMPLETE, workingDir);
observer.update(this, msg);
Logger rootLogger = Logger.getRootLogger();
@ -217,6 +218,14 @@ public abstract class AbstractRipper
fa.setFile("ripme.log");
fa.activateOptions();
}
if (Utils.getConfigBoolean("urls_only.save", false)) {
String urlFile = this.workingDir + File.separator + "urls.txt";
try {
Desktop.getDesktop().open(new File(urlFile));
} catch (IOException e) {
logger.warn("Error while opening " + urlFile, e);
}
}
}
}

View File

@ -1,6 +1,7 @@
package com.rarchives.ripme.ripper;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@ -41,15 +42,32 @@ public abstract class AlbumRipper extends AbstractRipper {
logger.info("[!] Skipping " + url + " -- already attempted: " + Utils.removeCWD(saveAs));
return;
}
itemsPending.put(url, saveAs);
DownloadFileThread dft = new DownloadFileThread(url, saveAs, this);
if (referrer != null) {
dft.setReferrer(referrer);
if (Utils.getConfigBoolean("urls_only.save", false)) {
// Output URL to file
String urlFile = this.workingDir + File.separator + "urls.txt";
try {
FileWriter fw = new FileWriter(urlFile, true);
fw.write(url.toExternalForm());
fw.write("\n");
fw.close();
RipStatusMessage msg = new RipStatusMessage(STATUS.DOWNLOAD_COMPLETE, urlFile);
itemsCompleted.put(url, new File(urlFile));
observer.update(this, msg);
} catch (IOException e) {
logger.error("Error while writing to " + urlFile, e);
}
}
if (cookies != null) {
dft.setCookies(cookies);
else {
itemsPending.put(url, saveAs);
DownloadFileThread dft = new DownloadFileThread(url, saveAs, this);
if (referrer != null) {
dft.setReferrer(referrer);
}
if (cookies != null) {
dft.setCookies(cookies);
}
threadPool.addThread(dft);
}
threadPool.addThread(dft);
}
@Override

View File

@ -110,6 +110,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
private static JCheckBox configSaveOrderCheckbox;
private static JCheckBox configShowPopup;
private static JCheckBox configSaveLogs;
private static JCheckBox configSaveURLsOnly;
private static TrayIcon trayIcon;
private static MenuItem trayMenuMain;
@ -176,6 +177,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
Utils.setConfigBoolean("download.save_order", configSaveOrderCheckbox.isSelected());
Utils.setConfigBoolean("download.show_popup", configShowPopup.isSelected());
Utils.setConfigBoolean("log.save", configSaveLogs.isSelected());
Utils.setConfigBoolean("urls_only.save", configSaveURLsOnly.isSelected());
saveHistory();
Utils.saveConfig();
}
@ -337,6 +339,9 @@ public class MainWindow implements Runnable, RipStatusHandler {
configSaveLogs = new JCheckBox("Save logs", Utils.getConfigBoolean("log.save", false));
configSaveLogs.setHorizontalAlignment(JCheckBox.RIGHT);
configSaveLogs.setHorizontalTextPosition(JCheckBox.LEFT);
configSaveURLsOnly = new JCheckBox("Save URLs only", Utils.getConfigBoolean("urls_only.save", false));
configSaveURLsOnly.setHorizontalAlignment(JCheckBox.RIGHT);
configSaveURLsOnly.setHorizontalTextPosition(JCheckBox.LEFT);
configSaveDirLabel = new JLabel();
try {
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));
@ -359,6 +364,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
gbc.gridy = 6; gbc.gridx = 0; configurationPanel.add(configPlaySound, gbc);
gbc.gridx = 1; configurationPanel.add(configSaveLogs, gbc);
gbc.gridy = 7; gbc.gridx = 0; configurationPanel.add(configShowPopup, gbc);
gbc.gridx = 1; configurationPanel.add(configSaveURLsOnly, gbc);
gbc.gridy = 8; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc);
gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc);
@ -560,6 +566,13 @@ public class MainWindow implements Runnable, RipStatusHandler {
Utils.configureLogger();
}
});
configSaveURLsOnly.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
Utils.setConfigBoolean("urls_only.save", configSaveURLsOnly.isSelected());
Utils.configureLogger();
}
});
}
private void setupTrayIcon() {
@ -704,7 +717,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
logText.setCaretPosition(sd.getLength());
}
private void loadHistory() {
for (String url : Utils.getConfigList("download.history")) {
historyListModel.addElement(url.trim());