From 61ed1e8e3417b5a747a1c812af0bbf91f0d6d1a1 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Tue, 3 Nov 2015 13:33:26 +0100 Subject: [PATCH] Prefer iTunes image over everything else --- .../core/syndication/namespace/NSITunes.java | 12 ++++++------ .../core/syndication/namespace/NSRSS20.java | 16 ++++++++++++---- .../core/syndication/namespace/atom/NSAtom.java | 4 +++- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSITunes.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSITunes.java index ff9828eba..6406295c1 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSITunes.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSITunes.java @@ -1,11 +1,12 @@ package de.danoeh.antennapod.core.syndication.namespace; -import de.danoeh.antennapod.core.feed.FeedImage; -import de.danoeh.antennapod.core.syndication.handler.HandlerState; import org.xml.sax.Attributes; import java.util.concurrent.TimeUnit; +import de.danoeh.antennapod.core.feed.FeedImage; +import de.danoeh.antennapod.core.syndication.handler.HandlerState; + public class NSITunes extends Namespace { public static final String NSTAG = "itunes"; public static final String NSURI = "http://www.itunes.com/dtds/podcast-1.0.dtd"; @@ -34,10 +35,9 @@ public class NSITunes extends Namespace { } else { // this is the feed image - if (state.getFeed().getImage() == null) { - image.setOwner(state.getFeed()); - state.getFeed().setImage(image); - } + // prefer to all other images + image.setOwner(state.getFeed()); + state.getFeed().setImage(image); } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSRSS20.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSRSS20.java index 25a57f71b..7e19213be 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSRSS20.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSRSS20.java @@ -5,6 +5,7 @@ import android.util.Log; import org.xml.sax.Attributes; import de.danoeh.antennapod.core.BuildConfig; +import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedImage; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; @@ -73,8 +74,11 @@ public class NSRSS20 extends Namespace { if (state.getTagstack().size() >= 1) { String parent = state.getTagstack().peek().getName(); if (parent.equals(CHANNEL)) { - state.getFeed().setImage(new FeedImage()); - state.getFeed().getImage().setOwner(state.getFeed()); + Feed feed = state.getFeed(); + if(feed.getImage() == null) { + feed.setImage(new FeedImage()); + feed.getImage().setOwner(state.getFeed()); + } } } } @@ -126,7 +130,9 @@ public class NSRSS20 extends Namespace { state.getFeed().setTitle(title); } else if (second.equals(IMAGE) && third != null && third.equals(CHANNEL)) { - state.getFeed().getImage().setTitle(title); + if(state.getFeed().getImage().getTitle() == null) { + state.getFeed().getImage().setTitle(title); + } } } else if (top.equals(LINK)) { if (second.equals(CHANNEL)) { @@ -139,7 +145,9 @@ public class NSRSS20 extends Namespace { DateUtils.parse(content)); } else if (top.equals(URL) && second.equals(IMAGE) && third != null && third.equals(CHANNEL)) { - state.getFeed().getImage().setDownload_url(content); + if(state.getFeed().getImage().getDownload_url() == null) { // prefer itunes:image + state.getFeed().getImage().setDownload_url(content); + } } else if (localName.equals(DESCR)) { if (second.equals(CHANNEL)) { state.getFeed().setDescription(content); diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java index abff5b2db..a690e7646 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java @@ -199,7 +199,9 @@ public class NSAtom extends Namespace { DateUtils.parse(content)); } } else if (top.equals(IMAGE)) { - state.getFeed().setImage(new FeedImage(state.getFeed(), content, null)); + if(state.getFeed().getImage() == null) { + state.getFeed().setImage(new FeedImage(state.getFeed(), content, null)); + } } }