Merge pull request #425 from cyian-1756/windows_file_system_fixes

Fixed imgur trying to add ?1 to filenames
This commit is contained in:
cyian-1756 2018-02-11 10:23:14 -05:00 committed by GitHub
commit aa334c51f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 8 deletions

View File

@ -51,14 +51,6 @@ public abstract class AlbumRipper extends AbstractRipper {
* Queues multiple URLs of single images to download from a single Album URL
*/
public boolean addURLToDownload(URL url, File saveAs, String referrer, Map<String,String> cookies) {
// TODO fix this hack
// Sanitize the saveAs file
String fileName = saveAs.getPath();
if (fileName.indexOf('?') >= 0) { fileName = fileName.substring(0, fileName.indexOf('?')); }
if (fileName.indexOf('&') >= 0) { fileName = fileName.substring(0, fileName.indexOf('&')); }
if (fileName.indexOf(':') >= 0) { fileName = fileName.substring(0, fileName.indexOf(':')); }
if (fileName.indexOf('#') >= 0) { fileName = fileName.substring(0, fileName.indexOf('#')); }
saveAs = new File(fileName);
// Only download one file if this is a test.
if (super.isThisATest() &&
(itemsPending.size() > 0 || itemsCompleted.size() > 0 || itemsErrored.size() > 0)) {

View File

@ -213,6 +213,7 @@ public class ImgurRipper extends AlbumRipper {
saveAs += String.format("%03d_", index);
}
saveAs += imgurImage.getSaveAs();
saveAs = saveAs.replaceAll("\\?\\d", "");
addURLToDownload(imgurImage.url, new File(saveAs));
}
}