diff --git a/src/de/danoeh/antennapod/syndication/handler/HandlerState.java b/src/de/danoeh/antennapod/syndication/handler/HandlerState.java index 810478bf5..6c206b8f3 100644 --- a/src/de/danoeh/antennapod/syndication/handler/HandlerState.java +++ b/src/de/danoeh/antennapod/syndication/handler/HandlerState.java @@ -57,6 +57,15 @@ public class HandlerState { return second; } + public SyndElement getThirdTag() { + SyndElement top = tagstack.pop(); + SyndElement second = tagstack.pop(); + SyndElement third = tagstack.peek(); + tagstack.push(second); + tagstack.push(top); + return third; + } + public StringBuffer getContentBuf() { return contentBuf; } diff --git a/src/de/danoeh/antennapod/syndication/namespace/rss20/NSRSS20.java b/src/de/danoeh/antennapod/syndication/namespace/rss20/NSRSS20.java index 46fe03bcf..388e1540e 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/rss20/NSRSS20.java +++ b/src/de/danoeh/antennapod/syndication/namespace/rss20/NSRSS20.java @@ -67,7 +67,12 @@ public class NSRSS20 extends Namespace { } } else if (localName.equals(IMAGE)) { - state.getFeed().setImage(new FeedImage()); + if (state.getTagstack().size() >= 1) { + String parent = state.getTagstack().peek().getName(); + if (parent.equals(CHANNEL)) { + state.getFeed().setImage(new FeedImage()); + } + } } return new SyndElement(localName, this); } @@ -83,6 +88,10 @@ public class NSRSS20 extends Namespace { String top = topElement.getName(); SyndElement secondElement = state.getSecondTag(); String second = secondElement.getName(); + String third = null; + if (state.getTagstack().size() >= 3) { + third = state.getThirdTag().getName(); + } if (top.equals(GUID) && second.equals(ITEM)) { state.getCurrentItem().setItemIdentifier(content); @@ -91,7 +100,7 @@ public class NSRSS20 extends Namespace { state.getCurrentItem().setTitle(content); } else if (second.equals(CHANNEL)) { state.getFeed().setTitle(content); - } else if (second.equals(IMAGE)) { + } else if (second.equals(IMAGE) && third != null && third.equals(CHANNEL)) { state.getFeed().getImage().setTitle(IMAGE); } } else if (top.equals(LINK)) { @@ -103,7 +112,7 @@ public class NSRSS20 extends Namespace { } else if (top.equals(PUBDATE) && second.equals(ITEM)) { state.getCurrentItem().setPubDate( SyndDateUtils.parseRFC822Date(content)); - } else if (top.equals(URL) && second.equals(IMAGE)) { + } else if (top.equals(URL) && second.equals(IMAGE) && third != null && third.equals(CHANNEL)) { state.getFeed().getImage().setDownload_url(content); } else if (localName.equals(DESCR)) { if (second.equals(CHANNEL)) { diff --git a/tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java b/tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java index 4b5b3e7dd..690f359fb 100644 --- a/tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java +++ b/tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java @@ -24,6 +24,7 @@ public class FeedHandlerTest extends AndroidTestCase { private static final String FEEDS_DIR = "testfeeds"; private static final String[] urls = { + "http://podcast.hr-online.de/lateline/podcast.xml", "http://bitlove.org/nsemak/mikrodilettanten/feed", "http://bitlove.org/moepmoeporg/riotburnz/feed", "http://bitlove.org/moepmoeporg/schachcast/feed",