1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-06 13:56:34 +02:00

Added ability to sanatize reddit titles saved as files.

This commit is contained in:
noesterle
2022-10-22 18:00:42 -04:00
committed by soloturn
parent dd307bc4c8
commit c9c46d6ae3

View File

@@ -292,7 +292,7 @@ public class RedditRipper extends AlbumRipper {
try { try {
saveFileAs = Utils.getPath(workingDir saveFileAs = Utils.getPath(workingDir
+ "/" + "/"
+ id + "_" + title + id + "_" + Utils.filesystemSafe(title)
+ ".html"); + ".html");
OutputStream out = Files.newOutputStream(saveFileAs); OutputStream out = Files.newOutputStream(saveFileAs);
out.write(html.getBytes()); out.write(html.getBytes());
@@ -411,12 +411,12 @@ public class RedditRipper extends AlbumRipper {
if (m.matches()) { if (m.matches()) {
// It's from reddituploads. Assume .jpg extension. // It's from reddituploads. Assume .jpg extension.
String savePath = this.workingDir + "/"; String savePath = this.workingDir + "/";
savePath += id + "-" + m.group(1) + title + ".jpg"; savePath += id + "-" + m.group(1) + Utils.filesystemSafe(title) + ".jpg";
addURLToDownload(urls.get(0), Utils.getPath(savePath)); addURLToDownload(urls.get(0), Utils.getPath(savePath));
} }
if (url.contains("v.redd.it")) { if (url.contains("v.redd.it")) {
String savePath = this.workingDir + "/"; String savePath = this.workingDir + "/";
savePath += id + "-" + url.split("/")[3] + title + ".mp4"; savePath += id + "-" + url.split("/")[3] + Utils.filesystemSafe(title) + ".mp4";
URL urlToDownload = parseRedditVideoMPD(urls.get(0).toExternalForm()); URL urlToDownload = parseRedditVideoMPD(urls.get(0).toExternalForm());
if (urlToDownload != null) { if (urlToDownload != null) {
LOGGER.info("url: " + urlToDownload + " file: " + savePath); LOGGER.info("url: " + urlToDownload + " file: " + savePath);
@@ -424,7 +424,7 @@ public class RedditRipper extends AlbumRipper {
} }
} }
else { else {
addURLToDownload(urls.get(0), id + title, "", theUrl, null); addURLToDownload(urls.get(0), Utils.filesystemSafe(id + title), "", theUrl, null);
} }
} else if (urls.size() > 1) { } else if (urls.size() > 1) {
for (int i = 0; i < urls.size(); i++) { for (int i = 0; i < urls.size(); i++) {