diff options
author | Tony Tam <149837+tonytamsf@users.noreply.github.com> | 2021-01-25 05:17:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-25 14:17:30 +0100 |
commit | f3bf708e260822645a65963ff402794cb0cca66e (patch) | |
tree | 29638576deda7b80f63b6c4f2db64e2701ccccb4 /core | |
parent | cd23eccf95d1a6c7193953c3f24a2fac4f32c97f (diff) | |
download | AntennaPod-f3bf708e260822645a65963ff402794cb0cca66e.zip |
Show publish date for podcasts and file creation date for local feeds (#4862)
Diffstat (limited to 'core')
3 files changed, 43 insertions, 1 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java index 4857e899d..b3b3d5c7a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java @@ -478,6 +478,18 @@ public class FeedMedia extends FeedFile implements Playable { } @Override + public Date getPubDate() { + if (item == null) { + return null; + } + if (item.getPubDate() != null) { + return item.getPubDate(); + } else { + return null; + } + } + + @Override public boolean localFileAvailable() { return isDownloaded() && file_url != null; } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/ExternalMedia.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/ExternalMedia.java index 6c107996f..39fceb27c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/ExternalMedia.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/ExternalMedia.java @@ -6,10 +6,16 @@ import android.content.SharedPreferences.Editor; import android.media.MediaMetadataRetriever; import android.os.Parcel; import android.os.Parcelable; +import android.text.TextUtils; import de.danoeh.antennapod.core.feed.Chapter; import de.danoeh.antennapod.core.feed.MediaType; import de.danoeh.antennapod.core.util.ChapterUtils; +import de.danoeh.antennapod.core.util.DateUtils; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.concurrent.Callable; import org.apache.commons.io.FilenameUtils; @@ -25,6 +31,7 @@ public class ExternalMedia implements Playable { private String episodeTitle; private String feedTitle; private MediaType mediaType; + private Date pubDate; private List<Chapter> chapters; private int duration; private int position; @@ -99,6 +106,19 @@ public class ExternalMedia implements Playable { e.printStackTrace(); throw new PlayableException("NumberFormatException when reading duration of media file"); } + + String dateStr = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DATE); + if (!TextUtils.isEmpty(dateStr)) { + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.getDefault()); + pubDate = simpleDateFormat.parse(dateStr); + } catch (ParseException parseException) { + pubDate = DateUtils.parse(dateStr); + } + } else { + pubDate = null; + } + setChapters(ChapterUtils.loadChaptersFromFileUrl(this)); } @@ -148,6 +168,11 @@ public class ExternalMedia implements Playable { } @Override + public Date getPubDate() { + return pubDate; + } + + @Override public int getPosition() { return position; } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java index 5b15913c8..59abdd10a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java @@ -13,7 +13,7 @@ import de.danoeh.antennapod.core.feed.MediaType; import de.danoeh.antennapod.core.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.util.ShownotesProvider; - +import java.util.Date; import java.util.List; /** @@ -68,6 +68,11 @@ public interface Playable extends Parcelable, String getFeedTitle(); /** + * Returns the published date + */ + Date getPubDate(); + + /** * Returns a unique identifier, for example a file url or an ID from a * database. */ |