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

View File

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