/**
* Create a new {@link PodcastItem} based on a {@link SyndEntry}.
*/
@SuppressWarnings("unchecked")
public static PodcastItem createPodcastItem(SyndEntry entry) {
PodcastItem item = new PodcastItem();
item.setDescription(getSyndContentValue(entry.getDescription()));
item.setPublishedDate(entry.getPublishedDate());
item.setTitle(entry.getTitle());
// Get the file url referred to in the podcast. Although specifications
// state that there may be more than one enclosure per file, I'll only
// care about one per file. Podcast entries referring to more than one
// file doesn't feel quite right...
List<SyndEnclosure> enclosures = entry.getEnclosures();
if (enclosures.isEmpty()) {
logger.warn("No enclosures found in item (uri=" + entry.getUri() + ")");
} else {
if (enclosures.size() > 1) {
logger.warn("Too many enclosures found in item (uri=" + entry.getUri() + "): " + enclosures.size());
}
// Use the first entry (there should be only one).
item.setFileUrl(enclosures.get(0).getUrl());
}
return item;
}