Use description of item if title is not available in RSS feed.

The title-tag of an item is optional in RSS 2 if a description-tag is
avialable.
This commit is contained in:
daniel oeh 2013-04-30 21:57:00 +02:00
parent 93964f2ac5
commit 6bbde80dd0
2 changed files with 14 additions and 2 deletions

View File

@ -78,6 +78,15 @@ public class NSRSS20 extends Namespace {
@Override @Override
public void handleElementEnd(String localName, HandlerState state) { public void handleElementEnd(String localName, HandlerState state) {
if (localName.equals(ITEM)) { if (localName.equals(ITEM)) {
if (state.getCurrentItem() != null) {
// the title tag is optional in RSS 2.0. The description is used
// as a
// title if the item has no title-tag.
if (state.getCurrentItem().getTitle() == null) {
state.getCurrentItem().setTitle(
state.getCurrentItem().getDescription());
}
}
state.setCurrentItem(null); state.setCurrentItem(null);
} else if (state.getTagstack().size() >= 2 } else if (state.getTagstack().size() >= 2
&& state.getContentBuf() != null) { && state.getContentBuf() != null) {
@ -98,7 +107,8 @@ public class NSRSS20 extends Namespace {
state.getCurrentItem().setTitle(content); state.getCurrentItem().setTitle(content);
} else if (second.equals(CHANNEL)) { } else if (second.equals(CHANNEL)) {
state.getFeed().setTitle(content); state.getFeed().setTitle(content);
} else if (second.equals(IMAGE) && third != null && third.equals(CHANNEL)) { } else if (second.equals(IMAGE) && third != null
&& third.equals(CHANNEL)) {
state.getFeed().getImage().setTitle(content); state.getFeed().getImage().setTitle(content);
} }
} else if (top.equals(LINK)) { } else if (top.equals(LINK)) {
@ -110,7 +120,8 @@ public class NSRSS20 extends Namespace {
} else if (top.equals(PUBDATE) && second.equals(ITEM)) { } else if (top.equals(PUBDATE) && second.equals(ITEM)) {
state.getCurrentItem().setPubDate( state.getCurrentItem().setPubDate(
SyndDateUtils.parseRFC822Date(content)); SyndDateUtils.parseRFC822Date(content));
} else if (top.equals(URL) && second.equals(IMAGE) && third != null && third.equals(CHANNEL)) { } else if (top.equals(URL) && second.equals(IMAGE) && third != null
&& third.equals(CHANNEL)) {
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)) {

View File

@ -3,6 +3,7 @@ package de.danoeh.antennapod.test;
public class TestFeeds { public class TestFeeds {
public static final String[] urls = { public static final String[] urls = {
"http://savoirsenmultimedia.ens.fr/podcast.php?id=30",
"http://bitlove.org/apollo40/ps3newsroom/feed", "http://bitlove.org/apollo40/ps3newsroom/feed",
"http://bitlove.org/beapirate/hauptstadtpiraten/feed", "http://bitlove.org/beapirate/hauptstadtpiraten/feed",
"http://bitlove.org/benni/besondereumstaende/feed", "http://bitlove.org/benni/besondereumstaende/feed",