Merge pull request #1333 from mfietz/issue/1332-gif-cover-art

Prefer iTunes image over everything else
This commit is contained in:
Tom Hennen 2015-11-03 18:51:36 -05:00
commit f684342ff5
3 changed files with 21 additions and 11 deletions

View File

@ -1,11 +1,12 @@
package de.danoeh.antennapod.core.syndication.namespace; 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 org.xml.sax.Attributes;
import java.util.concurrent.TimeUnit; 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 class NSITunes extends Namespace {
public static final String NSTAG = "itunes"; public static final String NSTAG = "itunes";
public static final String NSURI = "http://www.itunes.com/dtds/podcast-1.0.dtd"; public static final String NSURI = "http://www.itunes.com/dtds/podcast-1.0.dtd";
@ -34,11 +35,10 @@ public class NSITunes extends Namespace {
} else { } else {
// this is the feed image // this is the feed image
if (state.getFeed().getImage() == null) { // prefer to all other images
image.setOwner(state.getFeed()); image.setOwner(state.getFeed());
state.getFeed().setImage(image); state.getFeed().setImage(image);
} }
}
} }

View File

@ -5,6 +5,7 @@ import android.util.Log;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import de.danoeh.antennapod.core.BuildConfig; 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.FeedImage;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.FeedMedia;
@ -73,8 +74,11 @@ public class NSRSS20 extends Namespace {
if (state.getTagstack().size() >= 1) { if (state.getTagstack().size() >= 1) {
String parent = state.getTagstack().peek().getName(); String parent = state.getTagstack().peek().getName();
if (parent.equals(CHANNEL)) { if (parent.equals(CHANNEL)) {
state.getFeed().setImage(new FeedImage()); Feed feed = state.getFeed();
state.getFeed().getImage().setOwner(state.getFeed()); if(feed.getImage() == null) {
feed.setImage(new FeedImage());
feed.getImage().setOwner(state.getFeed());
}
} }
} }
} }
@ -126,8 +130,10 @@ public class NSRSS20 extends Namespace {
state.getFeed().setTitle(title); state.getFeed().setTitle(title);
} else if (second.equals(IMAGE) && third != null } else if (second.equals(IMAGE) && third != null
&& third.equals(CHANNEL)) { && third.equals(CHANNEL)) {
if(state.getFeed().getImage().getTitle() == null) {
state.getFeed().getImage().setTitle(title); state.getFeed().getImage().setTitle(title);
} }
}
} else if (top.equals(LINK)) { } else if (top.equals(LINK)) {
if (second.equals(CHANNEL)) { if (second.equals(CHANNEL)) {
state.getFeed().setLink(content); state.getFeed().setLink(content);
@ -139,7 +145,9 @@ public class NSRSS20 extends Namespace {
DateUtils.parse(content)); DateUtils.parse(content));
} else if (top.equals(URL) && second.equals(IMAGE) && third != null } else if (top.equals(URL) && second.equals(IMAGE) && third != null
&& third.equals(CHANNEL)) { && third.equals(CHANNEL)) {
if(state.getFeed().getImage().getDownload_url() == null) { // prefer itunes:image
state.getFeed().getImage().setDownload_url(content); state.getFeed().getImage().setDownload_url(content);
}
} else if (localName.equals(DESCR)) { } else if (localName.equals(DESCR)) {
if (second.equals(CHANNEL)) { if (second.equals(CHANNEL)) {
state.getFeed().setDescription(content); state.getFeed().setDescription(content);

View File

@ -199,8 +199,10 @@ public class NSAtom extends Namespace {
DateUtils.parse(content)); DateUtils.parse(content));
} }
} else if (top.equals(IMAGE)) { } else if (top.equals(IMAGE)) {
if(state.getFeed().getImage() == null) {
state.getFeed().setImage(new FeedImage(state.getFeed(), content, null)); state.getFeed().setImage(new FeedImage(state.getFeed(), content, null));
} }
}
} }
} }