check if the feed has changed by using publishDate of the feed or the first entry

This commit is contained in:
Athou
2013-04-19 11:51:40 +02:00
parent f8a7241bc1
commit 7502707930
5 changed files with 73 additions and 6 deletions

View File

@@ -39,8 +39,9 @@ public class FeedParser {
try {
InputSource source = new InputSource(new ByteArrayInputStream(xml));
if (new String(ArrayUtils.subarray(xml, 0, 100)).split(SystemUtils.LINE_SEPARATOR)[0]
.toUpperCase().contains("ISO-8859-1")) {
if (new String(ArrayUtils.subarray(xml, 0, 100))
.split(SystemUtils.LINE_SEPARATOR)[0].toUpperCase()
.contains("ISO-8859-1")) {
// they probably use word, we need to handle curly quotes and
// other word special characters
source.setEncoding("windows-1252");
@@ -70,6 +71,13 @@ public class FeedParser {
feed.getEntries().add(entry);
}
Date publishedDate = rss.getPublishedDate();
if (publishedDate == null && !feed.getEntries().isEmpty()) {
FeedEntry first = feed.getEntries().iterator().next();
publishedDate = first.getUpdated();
}
feed.setPublishedDate(publishedDate);
} catch (Exception e) {
throw new FeedException(String.format(
"Could not parse feed from %s : %s", feedUrl,