mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
fix #29
This commit is contained in:
@@ -17,7 +17,9 @@ import com.commafeed.backend.model.Feed;
|
||||
import com.commafeed.backend.model.FeedEntry;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sun.syndication.feed.synd.SyndContent;
|
||||
import com.sun.syndication.feed.synd.SyndEnclosure;
|
||||
import com.sun.syndication.feed.synd.SyndEntry;
|
||||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
@@ -51,6 +53,13 @@ public class FeedParser {
|
||||
entry.setUrl(item.getLink());
|
||||
entry.setUpdated(getUpdateDate(item));
|
||||
|
||||
SyndEnclosure enclosure = (SyndEnclosure) Iterables.getFirst(
|
||||
item.getEnclosures(), null);
|
||||
if (enclosure != null) {
|
||||
entry.setEnclosureUrl(enclosure.getUrl());
|
||||
entry.setEnclosureType(enclosure.getType());
|
||||
}
|
||||
|
||||
feed.getEntries().add(entry);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -37,6 +37,12 @@ public class FeedEntry extends AbstractModel {
|
||||
@Column(length = Integer.MAX_VALUE)
|
||||
private String content;
|
||||
|
||||
@Column(length = 2048)
|
||||
private String enclosureUrl;
|
||||
|
||||
@Column(length = 255)
|
||||
private String enclosureType;
|
||||
|
||||
@Column(length = 2048)
|
||||
private String url;
|
||||
|
||||
@@ -115,4 +121,20 @@ public class FeedEntry extends AbstractModel {
|
||||
this.inserted = inserted;
|
||||
}
|
||||
|
||||
public String getEnclosureUrl() {
|
||||
return enclosureUrl;
|
||||
}
|
||||
|
||||
public void setEnclosureUrl(String enclosureUrl) {
|
||||
this.enclosureUrl = enclosureUrl;
|
||||
}
|
||||
|
||||
public String getEnclosureType() {
|
||||
return enclosureType;
|
||||
}
|
||||
|
||||
public void setEnclosureType(String enclosureType) {
|
||||
this.enclosureType = enclosureType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ public class Entry implements Serializable {
|
||||
private String id;
|
||||
private String title;
|
||||
private String content;
|
||||
private String enclosureUrl;
|
||||
private String enclosureType;
|
||||
private Date date;
|
||||
private String feedId;
|
||||
private String feedName;
|
||||
@@ -97,4 +99,20 @@ public class Entry implements Serializable {
|
||||
this.feedUrl = feedUrl;
|
||||
}
|
||||
|
||||
public String getEnclosureUrl() {
|
||||
return enclosureUrl;
|
||||
}
|
||||
|
||||
public void setEnclosureUrl(String enclosureUrl) {
|
||||
this.enclosureUrl = enclosureUrl;
|
||||
}
|
||||
|
||||
public String getEnclosureType() {
|
||||
return enclosureType;
|
||||
}
|
||||
|
||||
public void setEnclosureType(String enclosureType) {
|
||||
this.enclosureType = enclosureType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -105,6 +105,8 @@ public class EntriesREST extends AbstractREST {
|
||||
entry.setId(String.valueOf(status.getId()));
|
||||
entry.setTitle(feedEntry.getTitle());
|
||||
entry.setContent(feedEntry.getContent());
|
||||
entry.setEnclosureUrl(status.getEntry().getEnclosureUrl());
|
||||
entry.setEnclosureType(status.getEntry().getEnclosureType());
|
||||
entry.setDate(feedEntry.getUpdated());
|
||||
entry.setUrl(feedEntry.getUrl());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user