1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-31 09:32:01 +02:00

addURLToDownload(url, saveAs) java.nio

This commit is contained in:
soloturn
2022-01-03 20:19:41 +01:00
parent 1422e32a43
commit 9016782248
9 changed files with 14 additions and 15 deletions

View File

@@ -345,8 +345,8 @@ public abstract class AbstractHTMLRipper extends AbstractRipper {
}
@Override
public boolean addURLToDownload(URL url, File saveAs) {
return addURLToDownload(url, saveAs, null, null, false);
public boolean addURLToDownload(URL url, Path saveAs) {
return addURLToDownload(url, saveAs.toFile(), null, null, false);
}
/**

View File

@@ -184,8 +184,8 @@ public abstract class AbstractJSONRipper extends AbstractRipper {
}
@Override
public boolean addURLToDownload(URL url, File saveAs) {
return addURLToDownload(url, saveAs, null, null, false);
public boolean addURLToDownload(URL url, Path saveAs) {
return addURLToDownload(url, saveAs.toFile(), null, null, false);
}
/**

View File

@@ -208,7 +208,7 @@ public abstract class AbstractRipper
* Path of the local file to save the content to.
* @return True on success, false on failure.
*/
public abstract boolean addURLToDownload(URL url, File saveAs);
public abstract boolean addURLToDownload(URL url, Path saveAs);
/**
* Queues image to be downloaded and saved.

View File

@@ -93,8 +93,8 @@ public abstract class AlbumRipper extends AbstractRipper {
}
@Override
public boolean addURLToDownload(URL url, File saveAs) {
return addURLToDownload(url, saveAs, null, null, false);
public boolean addURLToDownload(URL url, Path saveAs) {
return addURLToDownload(url, saveAs.toFile(), null, null, false);
}
/**

View File

@@ -44,8 +44,7 @@ public abstract class VideoRipper extends AbstractRipper {
}
@Override
public boolean addURLToDownload(URL url, File saveAsF) {
Path saveAs = saveAsF.toPath();
public boolean addURLToDownload(URL url, Path saveAs) {
if (Utils.getConfigBoolean("urls_only.save", false)) {
// Output URL to file
String urlFile = this.workingDir + "/urls.txt";
@@ -75,7 +74,7 @@ public abstract class VideoRipper extends AbstractRipper {
@Override
public boolean addURLToDownload(URL url, File saveAs, String referrer, Map<String, String> cookies, Boolean getFileExtFromMIME) {
return addURLToDownload(url, saveAs);
return addURLToDownload(url, saveAs.toPath());
}
/**

View File

@@ -249,7 +249,7 @@ public class EHentaiRipper extends AbstractHTMLRipper {
savePath += String.format("%03d_", index);
}
savePath += m.group(1);
addURLToDownload(new URL(imgsrc), Paths.get(savePath).toFile());
addURLToDownload(new URL(imgsrc), Paths.get(savePath));
} else {
// Provide prefix and let the AbstractRipper "guess" the filename
String prefix = "";

View File

@@ -230,7 +230,7 @@ public class ImgurRipper extends AlbumRipper {
}
saveAs += imgurImage.getSaveAs();
saveAs = saveAs.replaceAll("\\?\\d", "");
addURLToDownload(imgurImage.url, new File(saveAs));
addURLToDownload(imgurImage.url, new File(saveAs).toPath());
}
}

View File

@@ -95,7 +95,7 @@ public class PahealRipper extends AbstractHTMLRipper {
+ "/"
+ Utils.filesystemSafe(new URI(name).getPath())
+ ext);
addURLToDownload(url, outFile.toFile());
addURLToDownload(url, outFile);
} catch (URISyntaxException ex) {
logger.error("Error while downloading URL " + url, ex);
}

View File

@@ -404,7 +404,7 @@ public class RedditRipper extends AlbumRipper {
// It's from reddituploads. Assume .jpg extension.
String savePath = this.workingDir + "/";
savePath += id + "-" + m.group(1) + title + ".jpg";
addURLToDownload(urls.get(0), Paths.get(savePath).toFile());
addURLToDownload(urls.get(0), Paths.get(savePath));
}
if (url.contains("v.redd.it")) {
String savePath = this.workingDir + "/";
@@ -412,7 +412,7 @@ public class RedditRipper extends AlbumRipper {
URL urlToDownload = parseRedditVideoMPD(urls.get(0).toExternalForm());
if (urlToDownload != null) {
LOGGER.info("url: " + urlToDownload + " file: " + savePath);
addURLToDownload(urlToDownload, Paths.get(savePath).toFile());
addURLToDownload(urlToDownload, Paths.get(savePath));
}
}
else {