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