1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-01-18 05:08:15 +01:00

Fix #211: Add Utils.filesystemSanitized and apply to filename prefix. (#213)

This commit is contained in:
metaprime 2017-11-17 02:37:02 -08:00 committed by GitHub
parent 5912eb9c8a
commit fad35d1afb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -183,6 +183,7 @@ public abstract class AbstractRipper
if (!subdirectory.equals("")) {
subdirectory = File.separator + subdirectory;
}
prefix = Utils.filesystemSanitized(prefix);
saveFileAs = new File(
workingDir.getCanonicalPath()
+ subdirectory

View File

@ -144,6 +144,7 @@ public class InstagramRipper extends AbstractHTMLRipper {
Long epoch = data.getLong("date");
Instant instant = Instant.ofEpochSecond(epoch);
String image_date = DateTimeFormatter.ofPattern("yyyy_MM_dd_hh:mm_").format(ZonedDateTime.ofInstant(instant, ZoneOffset.UTC));
try {
if (!data.getBoolean("is_video")) {
if (imageURLs.size() == 0) {
@ -158,8 +159,8 @@ public class InstagramRipper extends AbstractHTMLRipper {
} catch (MalformedURLException e) {
return imageURLs;
}
nextPageID = data.getString("id");
nextPageID = data.getString("id");
if (isThisATest()) {
break;

View File

@ -355,6 +355,11 @@ public class Utils {
+ path.substring(path.length() - SHORTENED_PATH_LENGTH);
}
public static String filesystemSanitized(String text) {
text = text.replaceAll("[^a-zA-Z0-9.-]", "_");
return text;
}
public static String filesystemSafe(String text) {
text = text.replaceAll("[^a-zA-Z0-9.-]", "_")
.replaceAll("__", "_")