From 59dd904c22d3a42f3b67666611ba4fd8ddfcdab1 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Tue, 10 Jul 2018 12:53:02 -0400 Subject: [PATCH] Now prints error when ripme can't get a files type from the stream --- .../com/rarchives/ripme/ripper/DownloadFileThread.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java index 10e4462c..4f189c3c 100644 --- a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java +++ b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java @@ -175,8 +175,13 @@ class DownloadFileThread extends Thread { // Check if we should get the file ext from the MIME type if (getFileExtFromMIME) { - String fileExt = URLConnection.guessContentTypeFromStream(bis).replaceAll("image/", ""); - saveAs = new File(saveAs.toString() + "." + fileExt); + String fileExt = URLConnection.guessContentTypeFromStream(bis); + if (fileExt != null) { + fileExt = fileExt.replaceAll("image/", ""); + saveAs = new File(saveAs.toString() + "." + fileExt); + } else { + logger.error("Was unable to get content type from stream"); + } } // If we're resuming a download we append data to the existing file if (statusCode == 206) {