Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class AbstractRipper
implements RipperInterface, Runnable {

protected static final Logger LOGGER = Logger.getLogger(AbstractRipper.class);
private final String URLHistoryFile = Utils.getURLHistoryFile();
private String URLHistoryFile = Utils.getURLHistoryFile();

public static final String USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36";
Expand Down Expand Up @@ -76,6 +76,8 @@ private void writeDownloadedURL(String downloadedURL) throws IOException {
FileWriter fw = null;
try {
File file = new File(URLHistoryFile);
LOGGER.debug("url_history.txt file: " + file.toString());

if (!new File(Utils.getConfigDir()).exists()) {
LOGGER.error("Config dir doesn't exist");
LOGGER.info("Making config dir");
Expand Down Expand Up @@ -236,6 +238,19 @@ protected abstract boolean addURLToDownload(URL url, File saveAs, String referre
* False if failed to download
*/
protected boolean addURLToDownload(URL url, String prefix, String subdirectory, String referrer, Map<String, String> cookies, String fileName, String extension, Boolean getFileExtFromMIME) {

// if a url_history.txt file exists in the default location, continue using that.
// otherwise, save the url_history.txt file to each individual directory
try {
if (!new File(Utils.getURLHistoryFile()).exists()) {
LOGGER.debug("Using " + workingDir.getCanonicalPath() + " for url_history.txt");
URLHistoryFile = workingDir.getCanonicalPath() + File.separator + "url_history.txt";
}
} catch (IOException e) {
LOGGER.debug("IOException. Will not process.");
return false;
}

// Don't re-add the url if it was downloaded in a previous rip
if (Utils.getConfigBoolean("remember.url_history", true) && !isThisATest()) {
if (hasDownloadedURL(url.toExternalForm())) {
Expand Down