gpt4 book ai didi

rss - Rome 1.0 生成的 rss 提要中缺少媒体内容标签

转载 作者:行者123 更新时间:2023-12-04 14:20:01 25 4
gpt4 key购买 nike

我正在尝试将一些媒体内容添加到我的 Rome 1.0 生成的 RSS 提要中。但是生成的提要没有我的媒体内容标签。我一直在 Internet 上寻找答案,但到目前为止还没有真正有用的网站。如何让我的媒体内容显示在我的 RSS 提要中?下面是我的代码:

public org.w3c.dom.Document createMrssFeed(List<Article> recentArticles, String category, String descr) throws Exception {

SyndCategory syndCategory = new SyndCategoryImpl();
syndCategory.setName(category);

List<SyndCategory> categories = new ArrayList<>();
categories.add(syndCategory);

feed.setFeedType("rss_2.0");
feed.setTitle("My feed title");
feed.setLink("http://myfeedlink.com");
feed.setDescription(descr);
feed.setCategories(categories);
feed.setPublishedDate(new Date());
feed.setCopyright("Feed copyright"));

List<SyndEntry> items = new ArrayList<SyndEntry>();

SyndEntry item;
SyndContent description;

for (Article article : recentArticles) {

item = new Item();
item.setTitle(article.getTitle());
item.setLink(createLink(article.getLink()));

description = new SyndContentImpl();
description.setType("text/plain");
description.setValue(article.getDescription());

item.setPublishedDate(article.getPublishedDate());
item.setDescription(description);

MediaContent[] contents = new MediaContent[1];
MediaContent image = new MediaContent( new UrlReference("http://me.com/movie2.jpg"));
contents[0] = image;
Metadata md = new Metadata();
Thumbnail[] thumbs = new Thumbnail[2];
thumbs[0] = new Thumbnail(new URI("http://me.com/movie2.jpg"));
thumbs[1] = new Thumbnail(new URI("http://me.com/movie2.jpg"));
md.setThumbnail( thumbs );
image.setMetadata( md );
MediaEntryModuleImpl module = new MediaEntryModuleImpl();
module.setMediaContents(contents);
item.getModules().add(module);

items.add(item);
}

feed.setEntries(items);
SyndFeedOutput output = new SyndFeedOutput();
org.w3c.dom.Document mrssFeed = output.outputW3CDom(feed);

return mrssFeed;
}

生成的内容如下:

<rss xmlns:atom="http://www.w3.org/2005/Atom"xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">

<channel>
<title>My feed title</title>
<link>http://myfeedlink</link>
<description>news,sports</description>
<category>staff article</category>
<copyright>...</copyright>
<lastBuildDate>Sun, 07 Jun 2015 00:36:31 EDT</lastBuildDate>
<pubDate/>
<item>
<description>Item description</description>
<guid>http://www.myitemlink.com</guid>
<link>http://www.myitemlink.com</link>
<pubDate>Thu, 28 May 2015 10:00:34 EDT</pubDate>
<title>My item title</title>
</item>
<item>
<description>Item 2 description</description>
<guid>http://www.myitem2link.com</guid>
<link>http://www.myitem2link.com</link>
<pubDate>Thu, 28 May 2015 10:00:34 EDT</pubDate>
<title>My item 2 title</title>
</item>
</channel>
</rss>

最佳答案

你能试试吗Rome 1.5.0 ?您的代码似乎可以正常工作,并且也会生成媒体标签。

关于rss - Rome 1.0 生成的 rss 提要中缺少媒体内容标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30712334/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com