This is how to integrate the Media Module (http://search.yahoo.com/mrss/) by Yahoo!
Getting the library:
Download the jar from java.net here - code there is not very useful.
Maven:
Add to your pom.xml this repository:
<repositories>
<repository>
<id>dist.wso2.org</id>
<name>dist.wso2.org</name>
<url>
http://dist.wso2.org/maven2/
</url>
</repository>
</repositories>
and this dependency:
<dependency>
<groupId>rome</groupId>
<artifactId>rome-mediarss</artifactId>
<!-- rome Yahoo! Media RSS Plugin for ROME , hosted on http://dist.wso2.org/maven2-->
<version>0.2.2</version>
</dependency>
Java Code:
You can iterate through your Media Content like this:
SyndFeed feed = input.build(new XmlReader( method.getResponseBodyAsStream() ));
List entries = feed.getEntries();
for( Object obj : entries ) {
SyndEntry e = (SyndEntry) obj;
MediaModule mediaModule = (MediaModule)e.getModule( MEDIA_NS );
if (mediaModule!=null && mediaModule instanceof MediaEntryModule ){
MediaEntryModule mentry = (MediaEntryModule ) mediaModule;
for (MediaGroup mg : mentry.getMediaGroups()) {
for (MediaContent mc : mg.getContents()) {
if (mc.getType()!=null && mc.getType().startsWith("image")) {
String imgUrl = mc.getReference().toString();
// etc...
}
}
}
}
In this case I was interested in getting image urls.
You can access the MediaRss JavaDoc here