Merge pull request #5054 from ByteHamster/always-update-cover

Better metadata for previewed episodes
This commit is contained in:
ByteHamster 2021-03-27 12:19:48 +01:00 committed by GitHub
commit b16868521a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 27 deletions

View File

@ -23,7 +23,6 @@ import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.request.RequestOptions;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.event.PlaybackPositionEvent;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
import de.danoeh.antennapod.core.glide.ApGlideSettings;
import de.danoeh.antennapod.core.util.ChapterUtils;
@ -94,7 +93,7 @@ public class CoverFragment extends Fragment {
}
private void displayMediaInfo(@NonNull Playable media) {
String pubDateStr = DateUtils.formatAbbrev(getActivity(), ((FeedMedia) media).getPubDate());
String pubDateStr = DateUtils.formatAbbrev(getActivity(), media.getPubDate());
txtvPodcastTitle.setText(StringUtils.stripToEmpty(media.getFeedTitle())
+ "\u00A0"
+ ""

View File

@ -27,18 +27,18 @@ public class RemoteMedia implements Playable {
public static final int PLAYABLE_TYPE_REMOTE_MEDIA = 3;
private String downloadUrl;
private String itemIdentifier;
private String feedUrl;
private String feedTitle;
private String episodeTitle;
private String episodeLink;
private String feedAuthor;
private String imageUrl;
private String feedLink;
private String mimeType;
private Date pubDate;
private String notes;
private final String downloadUrl;
private final String itemIdentifier;
private final String feedUrl;
private final String feedTitle;
private final String episodeTitle;
private final String episodeLink;
private final String feedAuthor;
private final String imageUrl;
private final String feedLink;
private final String mimeType;
private final Date pubDate;
private final String notes;
private List<Chapter> chapters;
private int duration;
private int position;
@ -46,7 +46,8 @@ public class RemoteMedia implements Playable {
public RemoteMedia(String downloadUrl, String itemId, String feedUrl, String feedTitle,
String episodeTitle, String episodeLink, String feedAuthor,
String imageUrl, String feedLink, String mimeType, Date pubDate) {
String imageUrl, String feedLink, String mimeType, Date pubDate,
String notes) {
this.downloadUrl = downloadUrl;
this.itemIdentifier = itemId;
this.feedUrl = feedUrl;
@ -58,6 +59,7 @@ public class RemoteMedia implements Playable {
this.feedLink = feedLink;
this.mimeType = mimeType;
this.pubDate = pubDate;
this.notes = notes;
}
public RemoteMedia(FeedItem item) {
@ -68,14 +70,15 @@ public class RemoteMedia implements Playable {
this.episodeTitle = item.getTitle();
this.episodeLink = item.getLink();
this.feedAuthor = item.getFeed().getAuthor();
this.imageUrl = item.getImageUrl();
if (!TextUtils.isEmpty(item.getImageUrl())) {
this.imageUrl = item.getImageUrl();
} else {
this.imageUrl = item.getFeed().getImageUrl();
}
this.feedLink = item.getFeed().getLink();
this.mimeType = item.getMedia().getMime_type();
this.pubDate = item.getPubDate();
}
public void setNotes(String notes) {
this.notes = notes;
this.notes = item.getDescription();
}
public String getEpisodeIdentifier() {
@ -294,8 +297,7 @@ public class RemoteMedia implements Playable {
public RemoteMedia createFromParcel(Parcel in) {
RemoteMedia result = new RemoteMedia(in.readString(), in.readString(), in.readString(),
in.readString(), in.readString(), in.readString(), in.readString(), in.readString(),
in.readString(), in.readString(), new Date(in.readLong()));
result.setNotes(in.readString());
in.readString(), in.readString(), new Date(in.readLong()), in.readString());
result.setDuration(in.readInt());
result.setPosition(in.readInt());
result.setLastPlayedTime(in.readLong());

View File

@ -225,6 +225,7 @@ public class CastUtils {
if (!imageList.isEmpty()) {
imageUrl = imageList.get(0).getUrl().toString();
}
String notes = metadata.getString(KEY_EPISODE_NOTES);
result = new RemoteMedia(media.getContentId(),
metadata.getString(KEY_EPISODE_IDENTIFIER),
metadata.getString(KEY_FEED_URL),
@ -235,11 +236,8 @@ public class CastUtils {
imageUrl,
metadata.getString(KEY_FEED_WEBSITE),
media.getContentType(),
metadata.getDate(MediaMetadata.KEY_RELEASE_DATE).getTime());
String notes = metadata.getString(KEY_EPISODE_NOTES);
if (!TextUtils.isEmpty(notes)) {
((RemoteMedia) result).setNotes(notes);
}
metadata.getDate(MediaMetadata.KEY_RELEASE_DATE).getTime(),
notes);
Log.d(TAG, "Converted MediaInfo into RemoteMedia");
}
if (result.getDuration() == 0 && media.getStreamDuration() > 0) {