pull/34/head
kunfei 5 years ago
parent de8fb74b8d
commit 8171c938a0
  1. 33
      app/src/main/java/io/legado/app/model/rss/RssParser.kt

@ -40,44 +40,38 @@ object RssParser {
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_TITLE, RSSKeywords.RSS_ITEM_TITLE,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
currentArticle.title = xmlPullParser.nextText().trim() currentArticle.title = xmlPullParser.nextText().trim()
} }
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_LINK, RSSKeywords.RSS_ITEM_LINK,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
currentArticle.link = xmlPullParser.nextText().trim() currentArticle.link = xmlPullParser.nextText().trim()
} }
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_AUTHOR, RSSKeywords.RSS_ITEM_AUTHOR,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
currentArticle.author = xmlPullParser.nextText().trim() currentArticle.author = xmlPullParser.nextText().trim()
} }
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_CATEGORY, RSSKeywords.RSS_ITEM_CATEGORY,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
currentArticle.categories.add(xmlPullParser.nextText().trim()) currentArticle.categories.add(xmlPullParser.nextText().trim())
} }
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_THUMBNAIL, RSSKeywords.RSS_ITEM_THUMBNAIL,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
currentArticle.image = currentArticle.image =
xmlPullParser.getAttributeValue(null, RSSKeywords.RSS_ITEM_URL) xmlPullParser.getAttributeValue(null, RSSKeywords.RSS_ITEM_URL)
} }
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_ENCLOSURE, RSSKeywords.RSS_ITEM_ENCLOSURE,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
val type = xmlPullParser.getAttributeValue(null, RSSKeywords.RSS_ITEM_TYPE) val type = xmlPullParser.getAttributeValue(null, RSSKeywords.RSS_ITEM_TYPE)
if (type != null && type.contains("image/")) { if (type != null && type.contains("image/")) {
currentArticle.image = currentArticle.image =
@ -87,8 +81,7 @@ object RssParser {
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_DESCRIPTION, RSSKeywords.RSS_ITEM_DESCRIPTION,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
val description = xmlPullParser.nextText() val description = xmlPullParser.nextText()
currentArticle.description = description.trim() currentArticle.description = description.trim()
if (currentArticle.image == null) { if (currentArticle.image == null) {
@ -98,8 +91,7 @@ object RssParser {
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_CONTENT, RSSKeywords.RSS_ITEM_CONTENT,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
val content = xmlPullParser.nextText().trim() val content = xmlPullParser.nextText().trim()
currentArticle.content = content currentArticle.content = content
if (currentArticle.image == null) { if (currentArticle.image == null) {
@ -109,8 +101,7 @@ object RssParser {
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_PUB_DATE, RSSKeywords.RSS_ITEM_PUB_DATE,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
val nextTokenType = xmlPullParser.next() val nextTokenType = xmlPullParser.next()
if (nextTokenType == XmlPullParser.TEXT) { if (nextTokenType == XmlPullParser.TEXT) {
currentArticle.pubDate = xmlPullParser.text.trim() currentArticle.pubDate = xmlPullParser.text.trim()
@ -121,15 +112,13 @@ object RssParser {
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_TIME, RSSKeywords.RSS_ITEM_TIME,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
currentArticle.pubDate = xmlPullParser.nextText() currentArticle.pubDate = xmlPullParser.nextText()
} }
xmlPullParser.name.equals( xmlPullParser.name.equals(
RSSKeywords.RSS_ITEM_GUID, RSSKeywords.RSS_ITEM_GUID,
ignoreCase = true ignoreCase = true
) ) -> if (insideItem) {
-> if (insideItem) {
currentArticle.guid = xmlPullParser.nextText().trim() currentArticle.guid = xmlPullParser.nextText().trim()
} }
} }

Loading…
Cancel
Save