diff options
author | ByteHamster <info@bytehamster.com> | 2022-01-25 22:08:05 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-01-25 22:08:05 +0100 |
commit | d4d506345b222406a41ddd2a49af5c208f76e236 (patch) | |
tree | a221bd74d64a9c8837504a74405fa12c0d7f8f87 /core/src/main | |
parent | c376be44dd14132dafe49e311714b637e3af61fd (diff) | |
download | antennapod-d4d506345b222406a41ddd2a49af5c208f76e236.zip |
Move mime type guessing out of MediaType enum
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java index 5d685c24f..7ddaa080a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java @@ -34,6 +34,7 @@ import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.feed.FeedPreferences; import de.danoeh.antennapod.model.playback.MediaType; +import de.danoeh.antennapod.parser.feed.util.MimeTypeUtils; public class LocalFeedUpdater { @@ -74,21 +75,8 @@ public class LocalFeedUpdater { List<DocumentFile> mediaFiles = new ArrayList<>(); Set<String> mediaFileNames = new HashSet<>(); for (DocumentFile file : documentFolder.listFiles()) { - String mime = file.getType(); - if (mime == null) { - continue; - } - - MediaType mediaType = MediaType.fromMimeType(mime); - if (mediaType == MediaType.UNKNOWN) { - String path = file.getUri().toString(); - int fileExtensionPosition = path.lastIndexOf('.'); - if (fileExtensionPosition >= 0) { - String extensionWithoutDot = path.substring(fileExtensionPosition + 1); - mediaType = MediaType.fromFileExtension(extensionWithoutDot); - } - } - + String mimeType = MimeTypeUtils.getMimeType(file.getType(), file.getUri().toString()); + MediaType mediaType = MediaType.fromMimeType(mimeType); if (mediaType == MediaType.AUDIO || mediaType == MediaType.VIDEO) { mediaFiles.add(file); mediaFileNames.add(file.getName()); |