Java Code Examples for com.rometools.rome.feed.rss.Enclosure#setLength()
The following examples show how to use
com.rometools.rome.feed.rss.Enclosure#setLength() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FoundEpisodesRssFeedView.java From podcastpedia-web with MIT License | 5 votes |
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Episode> episodes = (List<Episode>) model.get("list_of_episodes"); List<Item> items = new ArrayList<Item>(episodes.size()); for (Episode episode : episodes) { Item item = new Item(); String date = String.format("%1$tY-%1$tm-%1$td", episode.getPublicationDate()); item.setTitle(episode.getTitle()); item.setPubDate(episode.getPublicationDate()); item.setLink(model.get("HOST_AND_PORT_URL") + "/podcasts/" + episode.getPodcastId() + "/" + episode.getPodcast().getTitleInUrl()+ "/episodes/" + episode.getEpisodeId() + "/" + episode.getTitleInUrl()); Description episodeDescription = new Description(); episodeDescription.setValue(episode.getDescription()); item.setDescription(episodeDescription); //set enclosures List<Enclosure> enclosures = new ArrayList<Enclosure>(); Enclosure enclosure = new Enclosure(); enclosure.setUrl(episode.getMediaUrl()); if(episode.getLength() != null) enclosure.setLength(episode.getLength()); if(episode.getEnclosureType() != null ) enclosure.setType(episode.getEnclosureType()); enclosures.add(enclosure); item.setEnclosures(enclosures); items.add(item); } return items; }
Example 2
Source File: GenericRssFeedView.java From podcastpedia-web with MIT License | 5 votes |
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Podcast> podcasts = (List<Podcast>) model.get("list_of_podcasts"); List<Item> items = new ArrayList<Item>(podcasts.size()); for (Podcast podcast : podcasts) { Episode episode = podcast.getLastEpisode(); Item item = new Item(); String date = String.format("%1$tY-%1$tm-%1$td", episode.getPublicationDate()); item.setTitle(podcast.getTitle()+ " - " + episode.getTitle()); item.setPubDate(podcast.getPublicationDate()); item.setLink( model.get("HOST_AND_PORT_URL") + "/podcasts/" + podcast.getPodcastId() + "/" + podcast.getTitleInUrl() ); Description episodeDescription = new Description(); episodeDescription.setValue(episode.getDescription()); item.setDescription(episodeDescription); //set enclosures List<Enclosure> enclosures = new ArrayList<Enclosure>(); Enclosure enclosure = new Enclosure(); enclosure.setUrl(episode.getMediaUrl()); if(episode.getLength() != null) enclosure.setLength(episode.getLength()); if(episode.getEnclosureType() != null ) enclosure.setType(episode.getEnclosureType()); enclosures.add(enclosure); item.setEnclosures(enclosures); items.add(item); } return items; }
Example 3
Source File: ConverterForRSS092.java From rome with Apache License 2.0 | 5 votes |
protected List<Enclosure> createEnclosures(final List<SyndEnclosure> sEnclosures) { final List<Enclosure> enclosures = new ArrayList<Enclosure>(); for (final SyndEnclosure sEnc : sEnclosures) { final Enclosure enc = new Enclosure(); enc.setUrl(sEnc.getUrl()); enc.setType(sEnc.getType()); enc.setLength(sEnc.getLength()); enclosures.add(enc); } return enclosures; }
Example 4
Source File: BasicPodfeedService.java From sakai with Educational Community License v2.0 | 4 votes |
/** * This add a particular podcast to the feed. * * @param title * The title for this podcast * @param mp3link * The URL where the podcast is stored * @param date * The publish date for this podcast * @param blogContent * The description of this podcast * @param cat * The category of entry this is (Podcast) * @param author * The author of this podcast * * @return * A SyndEntryImpl for this podcast */ private Item addPodcast(Map values) { final Item item = new Item(); // set title for this podcast item.setTitle((String) values.get("title")); // Replace all occurrences of pattern (ie, spaces) in input // with hex equivalent (%20) Pattern pattern = Pattern.compile(" "); String url = (String) values.get("url"); Matcher matcher = pattern.matcher(url); url = matcher.replaceAll("%20"); item.setLink(url); // Set Publish date for this podcast/episode // NOTE: date has local time, but when feed rendered, // converts it to GMT item.setPubDate((Date) values.get("date")); // Set description for this podcast/episode final Description itemDescription = new Description(); itemDescription.setType(DESCRIPTION_CONTENT_TYPE); itemDescription.setValue((String) values.get("description")); item.setDescription(itemDescription); // Set guid for this podcast/episode item.setGuid(new Guid()); item.getGuid().setValue((String) values.get("guid")); item.getGuid().setPermaLink(false); // This creates the enclosure so podcatchers (iTunes) can // find the podcasts List enclosures = new ArrayList(); final Enclosure enc = new Enclosure(); enc.setUrl(url); enc.setType((String) values.get("type")); enc.setLength((Long) values.get("len")); enclosures.add(enc); item.setEnclosures(enclosures); // Currently uses 2 modules: // iTunes for podcasting // DCmodule since validators want email with author tag, // so use dc:creator instead List modules = new ArrayList(); // Generate the iTunes tags final EntryInformation iTunesModule = new EntryInformationImpl(); iTunesModule.setAuthor(getMessageBundleString(FEED_ITEM_AUTHOR_STRING)); iTunesModule.setSummary((String) values.get("description")); // Set dc:creator tag final DCModuleImpl dcModule = new DCModuleImpl(); dcModule.setCreator((String) values.get("author")); modules.add(iTunesModule); modules.add(dcModule); item.setModules(modules); return item; }
Example 5
Source File: BasicPodfeedService.java From sakai with Educational Community License v2.0 | 4 votes |
/** * This add a particular podcast to the feed. * * @param title * The title for this podcast * @param mp3link * The URL where the podcast is stored * @param date * The publish date for this podcast * @param blogContent * The description of this podcast * @param cat * The category of entry this is (Podcast) * @param author * The author of this podcast * * @return * A SyndEntryImpl for this podcast */ private Item addPodcast(Map values) { final Item item = new Item(); // set title for this podcast item.setTitle((String) values.get("title")); // Replace all occurrences of pattern (ie, spaces) in input // with hex equivalent (%20) Pattern pattern = Pattern.compile(" "); String url = (String) values.get("url"); Matcher matcher = pattern.matcher(url); url = matcher.replaceAll("%20"); item.setLink(url); // Set Publish date for this podcast/episode // NOTE: date has local time, but when feed rendered, // converts it to GMT item.setPubDate((Date) values.get("date")); // Set description for this podcast/episode final Description itemDescription = new Description(); itemDescription.setType(DESCRIPTION_CONTENT_TYPE); itemDescription.setValue((String) values.get("description")); item.setDescription(itemDescription); // Set guid for this podcast/episode item.setGuid(new Guid()); item.getGuid().setValue((String) values.get("guid")); item.getGuid().setPermaLink(false); // This creates the enclosure so podcatchers (iTunes) can // find the podcasts List enclosures = new ArrayList(); final Enclosure enc = new Enclosure(); enc.setUrl(url); enc.setType((String) values.get("type")); enc.setLength((Long) values.get("len")); enclosures.add(enc); item.setEnclosures(enclosures); // Currently uses 2 modules: // iTunes for podcasting // DCmodule since validators want email with author tag, // so use dc:creator instead List modules = new ArrayList(); // Generate the iTunes tags final EntryInformation iTunesModule = new EntryInformationImpl(); iTunesModule.setAuthor(getMessageBundleString(FEED_ITEM_AUTHOR_STRING)); iTunesModule.setSummary((String) values.get("description")); // Set dc:creator tag final DCModuleImpl dcModule = new DCModuleImpl(); dcModule.setCreator((String) values.get("author")); modules.add(iTunesModule); modules.add(dcModule); item.setModules(modules); return item; }