mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 19:04:52 +01:00
Guess image file type and ignore when not an image
Apparently, some publishers explicitly specify the audio file as an image.
This commit is contained in:
parent
63c00a12a8
commit
d848ec3b98
@ -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 {
|
||||
|
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user