Fixing RSS content tag parsing, there may be more than one

This commit is contained in:
Shinokuni 2019-02-11 18:16:01 +00:00
parent 385dc05691
commit 518cada73f
2 changed files with 20 additions and 9 deletions

View File

@ -6,6 +6,7 @@ import com.readrops.app.utils.DateUtils;
import com.readrops.readropslibrary.localfeed.atom.ATOMEntry;
import com.readrops.readropslibrary.localfeed.json.JSONItem;
import com.readrops.readropslibrary.localfeed.rss.RSSItem;
import com.readrops.readropslibrary.localfeed.rss.RSSMediaContent;
import org.joda.time.LocalDateTime;
@ -175,8 +176,15 @@ public class Item {
newItem.setLink(item.getLink());
newItem.setFeedId(feed.getId());
if (item.getMediaContent() != null && item.getMediaContent().isContentAnImage())
newItem.setImageLink(item.getMediaContent().getUrl());
if (item.getMediaContents() != null && item.getMediaContents().size() > 0) {
for (RSSMediaContent mediaContent : item.getMediaContents()) {
if (mediaContent.isContentAnImage()) {
newItem.setImageLink(mediaContent.getUrl());
break;
}
}
}
dbItems.add(newItem);
}

View File

@ -3,9 +3,12 @@ package com.readrops.readropslibrary.localfeed.rss;
import com.readrops.readropslibrary.localfeed.AItem;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.Root;
import java.util.List;
@Root(name = "item", strict = false)
public class RSSItem extends AItem {
@ -21,9 +24,9 @@ public class RSSItem extends AItem {
@Element(name = "imageLink", required = false)
private String imageLink;
@Element(name = "content", required = false)
@ElementList(name = "content", inline = true, required = false)
@Namespace(prefix = "media")
private RSSMediaContent mediaContent;
private List<RSSMediaContent> mediaContents;
@Element(name = "creator", required = false)
@Namespace(prefix = "dc", reference = "http://purl.org/dc/elements/1.1/")
@ -32,7 +35,7 @@ public class RSSItem extends AItem {
@Element(name = "pubDate", required = false)
private String pubDate;
@Element(name = "encoded",required = false, data = true)
@Element(name = "encoded", required = false)
@Namespace(prefix = "content")
private String content;
@ -103,11 +106,11 @@ public class RSSItem extends AItem {
this.guid = guid;
}
public RSSMediaContent getMediaContent() {
return mediaContent;
public List<RSSMediaContent> getMediaContents() {
return mediaContents;
}
public void setMediaContent(RSSMediaContent mediaContent) {
this.mediaContent = mediaContent;
public void setMediaContents(List<RSSMediaContent> mediaContents) {
this.mediaContents = mediaContents;
}
}