mirror of https://github.com/readrops/Readrops.git
Fix some RSS2 parsing issues
This commit is contained in:
parent
f6f8807b3a
commit
ccce0a810d
|
@ -2,7 +2,7 @@
|
|||
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
|
||||
<channel>
|
||||
<title></title>
|
||||
<atom:link href="https://news.ycombinator.com/feed/" />
|
||||
<atom:link href="https://news.ycombinator.com/feed/" rel="self"/>
|
||||
<link>https://news.ycombinator.com/</link>
|
||||
<description>Links for the intellectually curious, ranked by readers.</description>
|
||||
</channel>
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
|
||||
<channel>
|
||||
<title>Hacker News</title>
|
||||
<atom:link href="https://news.ycombinator.com/feed/" />
|
||||
<atom:link href="https://news.ycombinator.com/feed/" rel="self" />
|
||||
<atom:link href="https://news.ycombinator.com/hub" rel="hub" />
|
||||
<link>https://news.ycombinator.com/</link>
|
||||
<description>Links for the intellectually curious, ranked by readers.</description>
|
||||
</channel>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0">
|
||||
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
|
||||
<channel>
|
||||
<title>Hacker News</title>
|
||||
<link>https://news.ycombinator.com/</link>
|
||||
|
@ -11,6 +11,7 @@
|
|||
<comments>https://news.ycombinator.com/item?id=24273602</comments>
|
||||
<author>Author 1</author>
|
||||
<description><![CDATA[<a href="https://news.ycombinator.com/item?id=24273602">Comments</a>]]></description>
|
||||
<media:description>media description</media:description>
|
||||
</item>
|
||||
<item>
|
||||
<title>Palantir S-1</title>
|
||||
|
|
|
@ -31,7 +31,7 @@ class RSSItemsAdapterTest {
|
|||
assertEquals(item.link, "https://www.bbc.com/news/world-africa-53887947")
|
||||
assertEquals(item.pubDate, DateUtils.stringToLocalDateTime("Tue, 25 Aug 2020 17:15:49 +0000"))
|
||||
assertEquals(item.author, "Author 1")
|
||||
assertNotNull(item.description)
|
||||
assertEquals(item.description, "<a href=\"https://news.ycombinator.com/item?id=24273602\">Comments</a>")
|
||||
assertEquals(item.guid, "https://www.bbc.com/news/world-africa-53887947")
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,13 @@ class RSSFeedAdapter : XmlAdapter<Feed> {
|
|||
with(feed) {
|
||||
when (tagName) {
|
||||
"title" -> name = Jsoup.parse(nonNullText()).text()
|
||||
"description" -> description = nullableText(failOnElement = false)
|
||||
"description" -> description = nullableText()
|
||||
"link" -> siteUrl = nullableText()
|
||||
"atom:link" -> url = attributes.getValueOpt("href")
|
||||
"atom:link" -> {
|
||||
if (attributes.getValueOpt("rel") == "self")
|
||||
url = attributes.getValueOpt("href")
|
||||
}
|
||||
else -> skipContents()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ class RSSItemsAdapter : XmlAdapter<List<Item>> {
|
|||
"content:encoded" -> content = nullableText()
|
||||
"enclosure" -> parseEnclosure(this, enclosures)
|
||||
"media:content" -> parseMediaContent(this, mediaContents)
|
||||
else -> skipContents() // for example media:description
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue