Ignore media content sub elements
This commit is contained in:
parent
ccce0a810d
commit
0eb518d692
api/src
androidTest/assets/localfeed/rss
main/java/com/readrops/api/localfeed/rss
@ -18,7 +18,7 @@
|
||||
|
||||
<description><![CDATA[description]]></description>
|
||||
<content:encoded><![CDATA[content:encoded]]></content:encoded>
|
||||
<media:content medium="image" url="https://image2.jpg" />
|
||||
<media:content medium="image" url="https://image2.jpg"><media:title>image2 title</media:title></media:content>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
@ -30,10 +30,15 @@ class RSSItemsAdapter : XmlAdapter<List<Item>> {
|
||||
"pubDate" -> pubDate = DateUtils.stringToLocalDateTime(nonNullText())
|
||||
"dc:date" -> pubDate = DateUtils.stringToLocalDateTime(nonNullText())
|
||||
"guid" -> guid = nullableText()
|
||||
"description" -> description = nullableText()
|
||||
"content:encoded" -> content = nullableText()
|
||||
"description" -> description = text(failOnElement = false)
|
||||
"content:encoded" -> content = nullableText(failOnElement = false)
|
||||
"enclosure" -> parseEnclosure(this, enclosures)
|
||||
"media:content" -> parseMediaContent(this, mediaContents)
|
||||
"media:group" -> allChildrenAutoIgnore("content") {
|
||||
when (tagName) {
|
||||
"media:content" -> parseMediaContent(this, mediaContents)
|
||||
}
|
||||
}
|
||||
else -> skipContents() // for example media:description
|
||||
}
|
||||
}
|
||||
@ -69,6 +74,8 @@ class RSSItemsAdapter : XmlAdapter<List<Item>> {
|
||||
if (konsume.attributes.getValueOpt("medium") != null
|
||||
&& LibUtils.isMimeImage(konsume.attributes["medium"]))
|
||||
mediaContents += konsume.attributes["url"]
|
||||
|
||||
konsume.skipContents() // ignore media content sub elements
|
||||
}
|
||||
|
||||
private fun validateItem(item: Item) {
|
||||
@ -81,6 +88,6 @@ class RSSItemsAdapter : XmlAdapter<List<Item>> {
|
||||
|
||||
companion object {
|
||||
val names = Names.of("title", "link", "author", "creator", "pubDate", "date",
|
||||
"guid", "description", "encoded", "enclosure", "content")
|
||||
"guid", "description", "encoded", "enclosure", "content", "group")
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user