Improve rss enclosure parsing

This commit is contained in:
Shinokuni 2019-02-19 11:47:59 +00:00
parent e89eb4f0de
commit c290551917
2 changed files with 15 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import com.readrops.app.utils.DateUtils;
import com.readrops.app.utils.Utils;
import com.readrops.readropslibrary.localfeed.atom.ATOMEntry;
import com.readrops.readropslibrary.localfeed.json.JSONItem;
import com.readrops.readropslibrary.localfeed.rss.RSSEnclosure;
import com.readrops.readropslibrary.localfeed.rss.RSSItem;
import com.readrops.readropslibrary.localfeed.rss.RSSMediaContent;
@ -187,8 +188,15 @@ public class Item {
}
}
} else {
if (item.getEnclosure() != null && Utils.isTypeImage(item.getEnclosure().getType()))
newItem.setImageLink(item.getEnclosure().getUrl());
if (item.getEnclosures() != null) {
for (RSSEnclosure enclosure : item.getEnclosures()) {
if (Utils.isTypeImage(enclosure.getType())) {
newItem.setImageLink(enclosure.getUrl());
break;
}
}
}
}
dbItems.add(newItem);

View File

@ -29,7 +29,7 @@ public class RSSItem extends AItem {
private List<RSSMediaContent> mediaContents;
@Element(required = false)
private RSSEnclosure enclosure;
private List<RSSEnclosure> enclosures;
@Element(name = "creator", required = false)
@Namespace(prefix = "dc", reference = "http://purl.org/dc/elements/1.1/")
@ -117,11 +117,11 @@ public class RSSItem extends AItem {
this.mediaContents = mediaContents;
}
public RSSEnclosure getEnclosure() {
return enclosure;
public List<RSSEnclosure> getEnclosures() {
return enclosures;
}
public void setEnclosure(RSSEnclosure enclosure) {
this.enclosure = enclosure;
public void setEnclosures(List<RSSEnclosure> enclosures) {
this.enclosures = enclosures;
}
}