Directories named after albums are sanitized first

This commit is contained in:
4pr0n 2014-04-11 22:35:46 -07:00
parent 4207a4f186
commit 1efac50834
2 changed files with 9 additions and 1 deletions

View File

@ -264,7 +264,9 @@ public abstract class AbstractRipper
if (!path.endsWith(File.separator)) { if (!path.endsWith(File.separator)) {
path += File.separator; path += File.separator;
} }
path += getAlbumTitle(this.url) + File.separator; String title = getAlbumTitle(this.url);
title = Utils.filesystemSafe(title);
path += title + File.separator;
this.workingDir = new File(path); this.workingDir = new File(path);
if (!this.workingDir.exists()) { if (!this.workingDir.exists()) {
logger.info("[+] Creating directory: " + Utils.removeCWD(this.workingDir)); logger.info("[+] Creating directory: " + Utils.removeCWD(this.workingDir));

View File

@ -241,4 +241,10 @@ public class Utils {
+ "..." + "..."
+ path.substring(path.length() - SHORTENED_PATH_LENGTH); + path.substring(path.length() - SHORTENED_PATH_LENGTH);
} }
public static String filesystemSafe(String text) {
return text.replaceAll("[^a-zA-Z0-9.-]", "_")
.replaceAll("__", "_")
.replaceAll("_+$", "");
}
} }