summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2021-07-31 20:43:42 +0200
committerByteHamster <info@bytehamster.com>2021-07-31 20:43:45 +0200
commitd848ec3b98d956c97845aa658e6cb2c3a4578588 (patch)
treea0c7f27848e81c0b78251f6eb071089d0835ec3a /core
parent63c00a12a85e0ff8d9017666d72280edb236557b (diff)
downloadAntennaPod-d848ec3b98d956c97845aa658e6cb2c3a4578588.zip
Guess image file type and ignore when not an image
Apparently, some publishers explicitly specify the audio file as an image.
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/glide/ResizingOkHttpStreamFetcher.java3
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSMedia.java8
2 files changed, 6 insertions, 5 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/glide/ResizingOkHttpStreamFetcher.java b/core/src/main/java/de/danoeh/antennapod/core/glide/ResizingOkHttpStreamFetcher.java
index 26f50e42f..7b8eed6e0 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/glide/ResizingOkHttpStreamFetcher.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/glide/ResizingOkHttpStreamFetcher.java
@@ -17,7 +17,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -103,7 +102,7 @@ public class ResizingOkHttpStreamFetcher extends OkHttpStreamFetcher {
callback.onDataReady(stream);
Log.d(TAG, "Compressed image from " + tempIn.length() / 1024
+ " to " + tempOut.length() / 1024 + " kB (quality: " + quality + "%)");
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
try {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSMedia.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSMedia.java
index 348ffaa60..3dba0735d 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSMedia.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSMedia.java
@@ -47,8 +47,8 @@ public class NSMedia extends Namespace {
String medium = attributes.getValue(MEDIUM);
boolean validTypeMedia = false;
boolean validTypeImage = false;
-
boolean isDefault = "true".equals(defaultStr);
+ String guessedType = SyndTypeUtils.getMimeTypeFromUrl(url);
if (MEDIUM_AUDIO.equals(medium)) {
validTypeMedia = true;
@@ -56,12 +56,14 @@ public class NSMedia extends Namespace {
} else if (MEDIUM_VIDEO.equals(medium)) {
validTypeMedia = true;
type = "video/*";
- } else if (MEDIUM_IMAGE.equals(medium)) {
+ } else if (MEDIUM_IMAGE.equals(medium) && (guessedType == null
+ || (!guessedType.startsWith("audio/") && !guessedType.startsWith("video/")))) {
+ // Apparently, some publishers explicitly specify the audio file as an image
validTypeImage = true;
type = "image/*";
} else {
if (type == null) {
- type = SyndTypeUtils.getMimeTypeFromUrl(url);
+ type = guessedType;
}
if (SyndTypeUtils.enclosureTypeValid(type)) {