Compare commits

...

1 commit

Author SHA1 Message Date
Patrick Gotthard
c447eda87b #244 Update iTunes module 2016-02-20 18:35:57 +01:00
11 changed files with 1719 additions and 1665 deletions

View file

@ -41,6 +41,7 @@
package com.rometools.modules.itunes; package com.rometools.modules.itunes;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
/** /**
* This is an abstract object that implements the attributes common across Feeds or Items in an * This is an abstract object that implements the attributes common across Feeds or Items in an
@ -75,7 +76,7 @@ public abstract class AbstractITunesObject implements ITunes, java.lang.Cloneabl
public static final String PREFIX = "itunes"; public static final String PREFIX = "itunes";
private String author; private String author;
private boolean block; private boolean block;
private boolean explicit; private Explicit explicit;
private URL image; private URL image;
private String[] keywords; private String[] keywords;
private String subtitle; private String subtitle;
@ -155,7 +156,7 @@ public abstract class AbstractITunesObject implements ITunes, java.lang.Cloneabl
* @return Boolean as to whether this feed or entry contains adult content * @return Boolean as to whether this feed or entry contains adult content
*/ */
@Override @Override
public boolean getExplicit() { public Explicit getExplicit() {
return explicit; return explicit;
} }
@ -165,7 +166,7 @@ public abstract class AbstractITunesObject implements ITunes, java.lang.Cloneabl
* @param explicit Boolean as to whether this feed or entry contains adult content * @param explicit Boolean as to whether this feed or entry contains adult content
*/ */
@Override @Override
public void setExplicit(final boolean explicit) { public void setExplicit(final Explicit explicit) {
this.explicit = explicit; this.explicit = explicit;
} }
@ -245,29 +246,23 @@ public abstract class AbstractITunesObject implements ITunes, java.lang.Cloneabl
@Override @Override
public String toString() { public String toString() {
final StringBuffer sb = new StringBuffer("["); StringBuilder builder = new StringBuilder();
sb.append(" Author: "); builder.append("AbstractITunesObject [author=");
sb.append(getAuthor()); builder.append(author);
sb.append(" Block: "); builder.append(", block=");
sb.append(getBlock()); builder.append(block);
sb.append(" Explicit: "); builder.append(", explicit=");
sb.append(getExplicit()); builder.append(explicit);
sb.append(" Image: "); builder.append(", image=");
sb.append(getImage()); builder.append(image);
sb.append(" Keywords: "); builder.append(", keywords=");
builder.append(Arrays.toString(keywords));
if (getKeywords() != null) { builder.append(", subtitle=");
for (int i = 0; i < keywords.length; i++) { builder.append(subtitle);
sb.append("'" + getKeywords()[i] + "'"); builder.append(", summary=");
} builder.append(summary);
builder.append("]");
return builder.toString();
} }
sb.append(" Subtitle: ");
sb.append(getSubtitle());
sb.append(" Summary: ");
sb.append(getSummary());
sb.append("]");
return sb.toString();
}
} }

View file

@ -52,6 +52,15 @@ import com.rometools.modules.itunes.types.Duration;
*/ */
public interface EntryInformation extends ITunes { public interface EntryInformation extends ITunes {
/**
* marker for closed captioning support on video.
*
* @see http://www.apple.com/itunes/podcasts/specs.html#isClosedCaptioned
*/
enum ClosedCaptioned {
yes, no
}
/** /**
* Returns the Duration object for this Item * Returns the Duration object for this Item
* *
@ -66,9 +75,9 @@ public interface EntryInformation extends ITunes {
*/ */
public void setDuration(Duration duration); public void setDuration(Duration duration);
public boolean getClosedCaptioned(); public ClosedCaptioned getClosedCaptioned();
public void setClosedCaptioned(boolean closedCaptioned); public void setClosedCaptioned(ClosedCaptioned closedCaptioned);
public Integer getOrder(); public Integer getOrder();

View file

@ -40,14 +40,14 @@
*/ */
package com.rometools.modules.itunes; package com.rometools.modules.itunes;
import com.rometools.modules.itunes.types.Duration; import java.net.MalformedURLException;
import com.rometools.rome.feed.CopyFrom; import java.net.URL;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.MalformedURLException; import com.rometools.modules.itunes.types.Duration;
import java.net.URL; import com.rometools.rome.feed.CopyFrom;
/** /**
* This class contains information for iTunes podcast feeds that exist at the Item level. * This class contains information for iTunes podcast feeds that exist at the Item level.
@ -64,7 +64,7 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
private static final Logger LOG = LoggerFactory.getLogger(EntryInformationImpl.class); private static final Logger LOG = LoggerFactory.getLogger(EntryInformationImpl.class);
private Duration duration; private Duration duration;
private boolean closedCaptioned; private ClosedCaptioned closedCaptioned;
private Integer order; private Integer order;
/** /**
@ -94,12 +94,12 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
} }
@Override @Override
public boolean getClosedCaptioned() { public ClosedCaptioned getClosedCaptioned() {
return closedCaptioned; return closedCaptioned;
} }
@Override @Override
public void setClosedCaptioned(boolean closedCaptioned) { public void setClosedCaptioned(final ClosedCaptioned closedCaptioned) {
this.closedCaptioned = closedCaptioned; this.closedCaptioned = closedCaptioned;
} }
@ -109,7 +109,7 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
} }
@Override @Override
public void setOrder(Integer order) { public void setOrder(final Integer order) {
this.order = order; this.order = order;
} }
@ -163,16 +163,15 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
@Override @Override
public String toString() { public String toString() {
final StringBuffer sb = new StringBuffer("["); StringBuilder builder = new StringBuilder();
sb.append(" duration: "); builder.append("EntryInformationImpl [duration=");
sb.append(getDuration()); builder.append(duration);
sb.append(" closedCaptioned: "); builder.append(", closedCaptioned=");
sb.append(getClosedCaptioned()); builder.append(closedCaptioned);
sb.append(" order: "); builder.append(", order=");
sb.append(getOrder()); builder.append(order);
sb.append("]"); builder.append("]");
sb.append(super.toString()); return builder.toString();
}
return sb.toString();
}
} }

View file

@ -67,13 +67,13 @@ public interface FeedInformation extends ITunes {
*/ */
public void setCategories(List<Category> categories); public void setCategories(List<Category> categories);
public boolean getComplete(); public Boolean getComplete();
public void setComplete(boolean complete); public void setComplete(Boolean complete);
public String getNewFeedUrl(); public URL getNewFeedUrl();
public void setNewFeedUrl(String newFeedUrl); public void setNewFeedUrl(URL newFeedUrl);
/** /**
* Sets the owner email address for the feed. * Sets the owner email address for the feed.

View file

@ -67,8 +67,8 @@ public class FeedInformationImpl extends AbstractITunesObject implements FeedInf
private String ownerName; private String ownerName;
private String ownerEmailAddress; private String ownerEmailAddress;
private List<Category> categories; private List<Category> categories;
private boolean complete; private Boolean complete;
private String newFeedUrl; private URL newFeedUrl;
/** /**
* Creates a new instance of FeedInformationImpl * Creates a new instance of FeedInformationImpl
@ -97,22 +97,22 @@ public class FeedInformationImpl extends AbstractITunesObject implements FeedInf
} }
@Override @Override
public boolean getComplete() { public Boolean getComplete() {
return complete; return complete;
} }
@Override @Override
public void setComplete(boolean complete) { public void setComplete(final Boolean complete) {
this.complete = complete; this.complete = complete;
} }
@Override @Override
public String getNewFeedUrl() { public URL getNewFeedUrl() {
return newFeedUrl; return newFeedUrl;
} }
@Override @Override
public void setNewFeedUrl(String newFeedUrl) { public void setNewFeedUrl(final URL newFeedUrl) {
this.newFeedUrl = newFeedUrl; this.newFeedUrl = newFeedUrl;
} }
@ -209,20 +209,19 @@ public class FeedInformationImpl extends AbstractITunesObject implements FeedInf
@Override @Override
public String toString() { public String toString() {
final StringBuffer sb = new StringBuffer("["); StringBuilder builder = new StringBuilder();
sb.append(" email: "); builder.append("FeedInformationImpl [ownerName=");
sb.append(getOwnerEmailAddress()); builder.append(ownerName);
sb.append(" name: "); builder.append(", ownerEmailAddress=");
sb.append(getOwnerName()); builder.append(ownerEmailAddress);
sb.append(" categories: "); builder.append(", categories=");
sb.append(getCategories()); builder.append(categories);
sb.append(" complete: "); builder.append(", complete=");
sb.append(getComplete()); builder.append(complete);
sb.append(" newFeedUrl: "); builder.append(", newFeedUrl=");
sb.append(getNewFeedUrl()); builder.append(newFeedUrl);
sb.append("]"); builder.append("]");
sb.append(super.toString()); return builder.toString();
}
return sb.toString();
}
} }

View file

@ -52,6 +52,15 @@ import java.net.URL;
*/ */
public interface ITunes extends Module { public interface ITunes extends Module {
/**
* Marker for podcasts containing explicit material.
*
* @see http://www.apple.com/itunes/podcasts/specs.html#explicit
*/
enum Explicit {
yes, no, clean
}
public static final String URI = AbstractITunesObject.URI; public static final String URI = AbstractITunesObject.URI;
/** /**
@ -83,18 +92,18 @@ public interface ITunes extends Module {
public void setBlock(boolean block); public void setBlock(boolean block);
/** /**
* Boolean as to whether this feed or entry contains adult content * whether this feed or entry contains adult content or not
* *
* @return Boolean as to whether this feed or entry contains adult content * @return explicit state as to whether this feed or entry contains adult content
*/ */
public boolean getExplicit(); public Explicit getExplicit();
/** /**
* Boolean as to whether this feed or entry contains adult content * whether this feed or entry contains adult content or not
* *
* @param explicit Boolean as to whether this feed or entry contains adult content * @param explicit explicit state as to whether this feed or entry contains adult content
*/ */
public void setExplicit(boolean explicit); public void setExplicit(Explicit explicit);
public URL getImage(); public URL getImage();

View file

@ -90,10 +90,10 @@ public class ITunesGenerator implements ModuleGenerator {
if (itunes instanceof FeedInformationImpl) { if (itunes instanceof FeedInformationImpl) {
// Do Channel Specific Stuff. // Do Channel Specific Stuff.
final FeedInformationImpl info = (FeedInformationImpl) itunes; final FeedInformationImpl info = (FeedInformationImpl) itunes;
final Element owner = generateSimpleElement("owner", ""); final Element owner = generateSimpleElement("owner", "");
final Element email = generateSimpleElement("email", info.getOwnerEmailAddress()); final Element email = generateSimpleElement("email", info.getOwnerEmailAddress());
owner.addContent(email); owner.addContent(email);
final Element name = generateSimpleElement("name", info.getOwnerName()); final Element name = generateSimpleElement("name", info.getOwnerName());
owner.addContent(name); owner.addContent(name);
element.addContent(owner); element.addContent(owner);
@ -113,12 +113,16 @@ public class ITunesGenerator implements ModuleGenerator {
element.addContent(category); element.addContent(category);
} }
if (info.getComplete() != null) {
if (info.getComplete()) { if (info.getComplete()) {
element.addContent(generateSimpleElement("complete", "yes")); element.addContent(generateSimpleElement("complete", "yes"));
} else {
element.addContent(generateSimpleElement("complete", "no"));
}
} }
if (info.getNewFeedUrl() != null) { if (info.getNewFeedUrl() != null) {
element.addContent(generateSimpleElement("new-feed-url", info.getNewFeedUrl())); element.addContent(generateSimpleElement("new-feed-url", info.getNewFeedUrl().toExternalForm()));
} }
} else if (itunes instanceof EntryInformationImpl) { } else if (itunes instanceof EntryInformationImpl) {
@ -127,8 +131,8 @@ public class ITunesGenerator implements ModuleGenerator {
if (info.getDuration() != null) { if (info.getDuration() != null) {
element.addContent(generateSimpleElement("duration", info.getDuration().toString())); element.addContent(generateSimpleElement("duration", info.getDuration().toString()));
} }
if (info.getClosedCaptioned()) { if (info.getClosedCaptioned() != null) {
element.addContent(generateSimpleElement("isClosedCaptioned", "yes")); element.addContent(generateSimpleElement("isClosedCaptioned", info.getClosedCaptioned().name()));
} }
if (info.getOrder() != null) { if (info.getOrder() != null) {
element.addContent(generateSimpleElement("order", info.getOrder().toString())); element.addContent(generateSimpleElement("order", info.getOrder().toString()));
@ -143,10 +147,8 @@ public class ITunesGenerator implements ModuleGenerator {
element.addContent(generateSimpleElement("block", "")); element.addContent(generateSimpleElement("block", ""));
} }
if (itunes.getExplicit()) { if (itunes.getExplicit() != null) {
element.addContent(generateSimpleElement("explicit", "yes")); element.addContent(generateSimpleElement("explicit", itunes.getExplicit().name()));
} else {
element.addContent(generateSimpleElement("explicit", "no"));
} }
if (itunes.getImage() != null) { if (itunes.getImage() != null) {

View file

@ -54,13 +54,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.rometools.modules.itunes.AbstractITunesObject; import com.rometools.modules.itunes.AbstractITunesObject;
import com.rometools.modules.itunes.EntryInformation;
import com.rometools.modules.itunes.EntryInformationImpl; import com.rometools.modules.itunes.EntryInformationImpl;
import com.rometools.modules.itunes.FeedInformationImpl; import com.rometools.modules.itunes.FeedInformationImpl;
import com.rometools.modules.itunes.ITunes;
import com.rometools.modules.itunes.types.Category; import com.rometools.modules.itunes.types.Category;
import com.rometools.modules.itunes.types.Duration; import com.rometools.modules.itunes.types.Duration;
import com.rometools.modules.itunes.types.Subcategory; import com.rometools.modules.itunes.types.Subcategory;
import com.rometools.rome.feed.module.Module;
import com.rometools.rome.io.ModuleParser; import com.rometools.rome.io.ModuleParser;
import com.rometools.rome.io.WireFeedParser; import com.rometools.rome.io.WireFeedParser;
import com.rometools.utils.Integers;
/** /**
* @version $Revision: 1.10 $ * @version $Revision: 1.10 $
@ -70,12 +74,23 @@ public class ITunesParser implements ModuleParser {
private static final Logger LOG = LoggerFactory.getLogger(ITunesParser.class); private static final Logger LOG = LoggerFactory.getLogger(ITunesParser.class);
Namespace ns = Namespace.getNamespace(AbstractITunesObject.URI); private final Namespace ns;
/** Creates a new instance of ITunesParser */ /** Creates a new instance of ITunesParser */
public ITunesParser() { public ITunesParser() {
this(Namespace.getNamespace(AbstractITunesObject.URI));
} }
/**
* @param ns target namespace
*/
protected ITunesParser(final Namespace ns) {
this.ns = ns;
}
/**
* @param feedParser ignored
*/
public void setParser(final WireFeedParser feedParser) { public void setParser(final WireFeedParser feedParser) {
} }
@ -85,7 +100,7 @@ public class ITunesParser implements ModuleParser {
} }
@Override @Override
public com.rometools.rome.feed.module.Module parse(final Element element, final Locale locale) { public Module parse(final Element element, final Locale locale) {
AbstractITunesObject module = null; AbstractITunesObject module = null;
if (element.getName().equals("channel")) { if (element.getName().equals("channel")) {
@ -135,7 +150,11 @@ public class ITunesParser implements ModuleParser {
final Element newFeedUrl = element.getChild("new-feed-url", ns); final Element newFeedUrl = element.getChild("new-feed-url", ns);
if (newFeedUrl != null) { if (newFeedUrl != null) {
feedInfo.setNewFeedUrl(newFeedUrl.getTextTrim()); try {
feedInfo.setNewFeedUrl(new URL(newFeedUrl.getTextTrim()));
} catch (final MalformedURLException e) {
LOG.debug("Malformed URL Exception reading itunes:new-feed-url tag: {}", newFeedUrl.getTextTrim());
}
} }
} else if (element.getName().equals("item")) { } else if (element.getName().equals("item")) {
@ -145,16 +164,15 @@ public class ITunesParser implements ModuleParser {
// Now I am going to get the item specific tags // Now I am going to get the item specific tags
final Element duration = element.getChild("duration", ns); final Element duration = element.getChild("duration", ns);
if (duration != null && duration.getValue() != null) { if (duration != null && duration.getValue() != null) {
final Duration dur = new Duration(duration.getValue().trim()); final Duration dur = new Duration(duration.getValue().trim());
entryInfo.setDuration(dur); entryInfo.setDuration(dur);
} }
final Element closedCaptioned = element.getChild("isClosedCaptioned", ns); final Element isClosedCaptioned = element.getChild("isClosedCaptioned", ns);
if (closedCaptioned != null && closedCaptioned.getValue() != null && closedCaptioned.getValue().trim().equalsIgnoreCase("yes")) { if (isClosedCaptioned != null && isClosedCaptioned.getValue() != null ) {
entryInfo.setClosedCaptioned(true); entryInfo.setClosedCaptioned(EntryInformation.ClosedCaptioned.valueOf(isClosedCaptioned.getTextTrim().toLowerCase()));
} }
final Element order = element.getChild("order", ns); final Element order = element.getChild("order", ns);
@ -175,13 +193,13 @@ public class ITunesParser implements ModuleParser {
final Element block = element.getChild("block", ns); final Element block = element.getChild("block", ns);
if (block != null) { if (block != null) {
module.setBlock(true); module.setBlock("yes".equals(block.getTextTrim().toLowerCase()));
} }
final Element explicit = element.getChild("explicit", ns); final Element explicit = element.getChild("explicit", ns);
if (explicit != null && explicit.getValue() != null && explicit.getValue().trim().equalsIgnoreCase("yes")) { if (explicit != null && explicit.getValue() != null) {
module.setExplicit(true); module.setExplicit(ITunes.Explicit.valueOf(explicit.getTextTrim().toLowerCase()));
} }
final Element keywords = element.getChild("keywords", ns); final Element keywords = element.getChild("keywords", ns);
@ -219,6 +237,7 @@ public class ITunesParser implements ModuleParser {
LOG.debug("Malformed URL Exception reading itunes:image tag: {}", image.getAttributeValue("href")); LOG.debug("Malformed URL Exception reading itunes:image tag: {}", image.getAttributeValue("href"));
} }
} }
} }
return module; return module;

View file

@ -47,12 +47,11 @@ import org.jdom2.Namespace;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class ITunesParserOldNamespace extends ITunesParser { public class ITunesParserOldNamespace extends ITunesParser {
String URI = "http://www.itunes.com/DTDs/Podcast-1.0.dtd"; private static final String URI = "http://www.itunes.com/DTDs/Podcast-1.0.dtd";
/** Creates a new instance of ITunesParserOldNamespace */ /** Creates a new instance of ITunesParserOldNamespace */
public ITunesParserOldNamespace() { public ITunesParserOldNamespace() {
super(); super(Namespace.getNamespace(URI));
super.ns = Namespace.getNamespace(URI);
} }
@Override @Override

View file

@ -7,26 +7,27 @@
package com.rometools.modules.itunes; package com.rometools.modules.itunes;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.rometools.modules.AbstractTestCase; import com.rometools.modules.AbstractTestCase;
import com.rometools.modules.itunes.AbstractITunesObject; import com.rometools.modules.itunes.EntryInformation.ClosedCaptioned;
import com.rometools.modules.itunes.EntryInformationImpl; import com.rometools.modules.itunes.ITunes.Explicit;
import com.rometools.modules.itunes.FeedInformationImpl;
import com.rometools.modules.itunes.io.ITunesGenerator; import com.rometools.modules.itunes.io.ITunesGenerator;
import com.rometools.rome.feed.module.Module; import com.rometools.rome.feed.module.Module;
import com.rometools.rome.feed.synd.SyndEntry; import com.rometools.rome.feed.synd.SyndEntry;
import com.rometools.rome.feed.synd.SyndFeed; import com.rometools.rome.feed.synd.SyndFeed;
import com.rometools.rome.io.FeedException;
import com.rometools.rome.io.SyndFeedInput; import com.rometools.rome.io.SyndFeedInput;
import com.rometools.rome.io.XmlReader; import com.rometools.rome.io.XmlReader;
import junit.framework.Test;
import junit.framework.TestSuite;
/** /**
* *
* @author cooper * @author cooper
@ -34,6 +35,7 @@ import com.rometools.rome.io.XmlReader;
public class ITunesParserTest extends AbstractTestCase { public class ITunesParserTest extends AbstractTestCase {
private static final Logger LOG = LoggerFactory.getLogger(ITunesParserTest.class); private static final Logger LOG = LoggerFactory.getLogger(ITunesParserTest.class);
private static final int itemCountInLeShowFeed = 4;
public ITunesParserTest(final String testName) { public ITunesParserTest(final String testName) {
super(testName); super(testName);
@ -81,8 +83,9 @@ public class ITunesParserTest extends AbstractTestCase {
"summary", "summary",
"A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.", "A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.",
feedInfo.getSummary()); feedInfo.getSummary());
assertEquals(true, feedInfo.getComplete()); assertEquals("complete", Boolean.TRUE, feedInfo.getComplete());
assertEquals("http://example.org", feedInfo.getNewFeedUrl()); assertEquals("new-feed-url", "http://newlocation.com/example.rss", feedInfo.getNewFeedUrl().toExternalForm());
assertFalse("block", feedInfo.getBlock());
List<SyndEntry> entries = syndfeed.getEntries(); List<SyndEntry> entries = syndfeed.getEntries();
Iterator<SyndEntry> it = entries.iterator(); Iterator<SyndEntry> it = entries.iterator();
@ -103,6 +106,7 @@ public class ITunesParserTest extends AbstractTestCase {
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI); final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
LOG.debug("{}", entryInfo.getDuration()); LOG.debug("{}", entryInfo.getDuration());
} }
} }
/** /**
@ -116,8 +120,123 @@ public class ITunesParserTest extends AbstractTestCase {
SyndEntry entry = syndfeed.getEntries().get(0); SyndEntry entry = syndfeed.getEntries().get(0);
EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI); EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
assertEquals(true, entryInfo.getClosedCaptioned()); assertEquals(ClosedCaptioned.yes, entryInfo.getClosedCaptioned());
assertEquals(Integer.valueOf(2), entryInfo.getOrder()); assertEquals(Integer.valueOf(2), entryInfo.getOrder());
assertEquals("http://example.org/image.png", entryInfo.getImage().toString()); assertEquals("http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg", entryInfo.getImage().toString());
}
/**
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testParseRsr() throws IOException, FeedException {
final SyndFeed syndfeed = getSyndFeed("xml/rsr.xml");
final List<SyndEntry> entries = syndfeed.getEntries();
final Iterator<SyndEntry> it = entries.iterator();
while (it.hasNext()) {
final SyndEntry entry = it.next();
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
LOG.debug("{}", entryInfo.getDuration());
}
}
/**
* test for itunes:explicit tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testImageTagOnItem() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
assertEquals("http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg",
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getImage().toExternalForm());
}
/**
* test for itunes:explicit tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testExplicitTags() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
final FeedInformationImpl feedInfo = (FeedInformationImpl) feed.getModule(AbstractITunesObject.URI);
assertEquals("explicit tag on feed", Explicit.yes, feedInfo.getExplicit());
assertEquals("wrong count of items", itemCountInLeShowFeed, feed.getEntries().size());
assertEquals("explicit tag on 1. item", Explicit.yes,
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getExplicit());
assertEquals("explicit tag on 2. item", Explicit.no,
((EntryInformation) feed.getEntries().get(1).getModule(AbstractITunesObject.URI)).getExplicit());
assertEquals("explicit tag on 3. item", Explicit.clean,
((EntryInformation) feed.getEntries().get(2).getModule(AbstractITunesObject.URI)).getExplicit());
assertNull("explicit tag on 4. item",
((EntryInformation) feed.getEntries().get(3).getModule(AbstractITunesObject.URI)).getExplicit());
}
/**
* test for itunes:isClosedCaptioned tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testClosedCaptionedTags() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
assertEquals("wrong count of items", itemCountInLeShowFeed, feed.getEntries().size());
assertEquals("isClosedCaptioned tag on 1. item", ClosedCaptioned.yes,
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getClosedCaptioned());
assertEquals("isClosedCaptioned tag on 2. item", ClosedCaptioned.no,
((EntryInformation) feed.getEntries().get(1).getModule(AbstractITunesObject.URI)).getClosedCaptioned());
assertEquals("isClosedCaptioned tag on 3. item", ClosedCaptioned.no,
((EntryInformation) feed.getEntries().get(2).getModule(AbstractITunesObject.URI)).getClosedCaptioned());
assertNull("isClosedCaptioned tag on 4. item",
((EntryInformation) feed.getEntries().get(3).getModule(AbstractITunesObject.URI)).getClosedCaptioned());
}
/**
* test for itunes:order tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testOrderTags() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
assertEquals("wrong count of items", itemCountInLeShowFeed, feed.getEntries().size());
assertEquals("order tag on 1. item", Integer.valueOf(2),
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getOrder());
assertEquals("order tag on 2. item", Integer.valueOf(1),
((EntryInformation) feed.getEntries().get(1).getModule(AbstractITunesObject.URI)).getOrder());
assertNull("order tag on 3. item",
((EntryInformation) feed.getEntries().get(2).getModule(AbstractITunesObject.URI)).getOrder());
assertNull("order tag on 4. item",
((EntryInformation) feed.getEntries().get(3).getModule(AbstractITunesObject.URI)).getOrder());
}
/**
* test for itunes:block tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testBlockTags() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
assertEquals("wrong count of items", itemCountInLeShowFeed, feed.getEntries().size());
assertTrue("block tag on 1. item",
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getBlock());
assertFalse("block tag on 2. item",
((EntryInformation) feed.getEntries().get(1).getModule(AbstractITunesObject.URI)).getBlock());
assertFalse("block tag on 3. item",
((EntryInformation) feed.getEntries().get(2).getModule(AbstractITunesObject.URI)).getBlock());
assertFalse("block tag on 4. item",
((EntryInformation) feed.getEntries().get(3).getModule(AbstractITunesObject.URI)).getBlock());
}
/**
* @param testfile path to test file
* @return SyndFeed from test file
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
private SyndFeed getSyndFeed(final String testfile) throws IOException, FeedException {
return new SyndFeedInput().build(new File(getTestFile(testfile)));
} }
} }

View file

@ -8,34 +8,19 @@
<itunes:subtitle>An hour&#39;s worth of Harry Shearer</itunes:subtitle> <itunes:subtitle>An hour&#39;s worth of Harry Shearer</itunes:subtitle>
<itunes:summary>A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.</itunes:summary> <itunes:summary>A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.</itunes:summary>
<itunes:complete>yes</itunes:complete> <itunes:complete>yes</itunes:complete>
<itunes:new-feed-url>http://example.org</itunes:new-feed-url> <itunes:new-feed-url>http://newlocation.com/example.rss</itunes:new-feed-url>
<language>en</language> <language>en</language>
<copyright>KCRW 2005</copyright> <copyright>KCRW 2005</copyright>
<itunes:owner> <itunes:owner>
<itunes:name>Harry Shearer</itunes:name> <itunes:name>Harry Shearer</itunes:name>
<itunes:email></itunes:email> <itunes:email></itunes:email>
</itunes:owner> </itunes:owner>
<itunes:image rel="image" href="http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg">KCRW&#39;s Le Show</itunes:image> <itunes:image rel="image" href="http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg">KCRW&#39;s Le Show</itunes:image>
<category>Comedy</category> <category>Comedy</category>
<itunes:category text="Comedy" /> <itunes:category text="Comedy" />
<itunes:category text="Comedy" /> <itunes:category text="Comedy" />
<itunes:block>no</itunes:block>
<itunes:explicit>yes</itunes:explicit>
<item> <item>
<title>le Show</title> <title>le Show</title>
<itunes:author>Harry Shearer</itunes:author> <itunes:author>Harry Shearer</itunes:author>
@ -44,146 +29,65 @@
<itunes:summary></itunes:summary> <itunes:summary></itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Podcasts/y2005/m08/d01/h14/eosmhmit.mp3" length="16770270" type="" /> <enclosure url="http://a1.phobos.apple.com/Podcasts/y2005/m08/d01/h14/eosmhmit.mp3" length="16770270" type="" />
<guid>http://66.186.18.80/podcast/mp3/ls/ls050731le_Show.mp3</guid> <guid>http://66.186.18.80/podcast/mp3/ls/ls050731le_Show.mp3</guid>
<pubDate>Sun, 31 Jul 2005 16:00:00 GMT</pubDate> <pubDate>Sun, 31 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category> <category>Comedy</category>
<itunes:category text="Comedy" /> <itunes:category text="Comedy" />
<itunes:category text="Comedy" /> <itunes:category text="Comedy" />
<itunes:explicit>yes</itunes:explicit>
<itunes:explicit>no</itunes:explicit>
<itunes:duration>46:34</itunes:duration> <itunes:duration>46:34</itunes:duration>
<itunes:keywords></itunes:keywords> <itunes:keywords></itunes:keywords>
<itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned> <itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned>
<itunes:order>2</itunes:order> <itunes:order>2</itunes:order>
<itunes:image href="http://example.org/image.png"></itunes:image> <itunes:image rel="image" href="http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg">KCRW&#39;s Le Show</itunes:image>
<itunes:block>yes</itunes:block>
</item> </item>
<item>
<title>le Show</title>
<itunes:author>Harry Shearer</itunes:author>
<description>
</description>
<itunes:subtitle>
</itunes:subtitle>
<itunes:summary>
</itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Podcasts/y2005/m07/d25/h15/kubgxyqj.mp3" length="15841460" type=""/>
<guid>http://66.186.18.80/podcast/mp3/ls/ls050724le_Show.mp3</guid>
<pubDate>Sun, 24 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category>
<itunes:category text="Comedy"/>
<itunes:category text="Comedy"/>
<itunes:explicit>no</itunes:explicit>
<itunes:duration>44:00</itunes:duration>
<itunes:keywords></itunes:keywords>
</item>
<item>
<title>le Show</title>
<itunes:author>Harry Shearer</itunes:author>
<description>
</description>
<itunes:subtitle>
</itunes:subtitle>
<itunes:summary>
</itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Features/y2005/m07/d18/h18/dj.mwuhgyyh.mp3" length="17483726" type=""/>
<guid>http://66.186.18.80/podcast/mp3/ls/ls050717le_Show.mp3</guid>
<pubDate>Sun, 17 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category>
<itunes:category text="Comedy"/>
<itunes:category text="Comedy"/>
<itunes:explicit>no</itunes:explicit>
<itunes:duration>48:33</itunes:duration>
<itunes:keywords></itunes:keywords>
</item>
<item> <item>
<title>le Show</title> <title>le Show</title>
<itunes:author>Harry Shearer</itunes:author> <itunes:author>Harry Shearer</itunes:author>
<description></description> <description></description>
<itunes:subtitle></itunes:subtitle> <itunes:subtitle></itunes:subtitle>
<itunes:summary></itunes:summary> <itunes:summary></itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Music/y2005/m07/d12/h14/axebmlyj.mp3" length="16541124" type=""/> <enclosure url="http://a1.phobos.apple.com/Podcasts/y2005/m07/d25/h15/kubgxyqj.mp3" length="15841460" type="" />
<guid>http://66.186.18.80/podcast/mp3/ls/ls050710le_Show.mp3</guid> <guid>http://66.186.18.80/podcast/mp3/ls/ls050724le_Show.mp3</guid>
<pubDate>Sun, 24 Jul 2005 16:00:00 GMT</pubDate>
<pubDate>Sun, 10 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category> <category>Comedy</category>
<itunes:category text="Comedy" /> <itunes:category text="Comedy" />
<itunes:category text="Comedy" /> <itunes:category text="Comedy" />
<itunes:explicit>no</itunes:explicit> <itunes:explicit>no</itunes:explicit>
<itunes:duration>44:00</itunes:duration>
<itunes:duration>45:56</itunes:duration> <itunes:block>no</itunes:block>
<itunes:isClosedCaptioned>no</itunes:isClosedCaptioned>
<itunes:order>1</itunes:order>
<itunes:keywords></itunes:keywords>
</item>
<item>
<title>le Show</title>
<itunes:author>Harry Shearer</itunes:author>
<description></description>
<itunes:subtitle></itunes:subtitle>
<itunes:summary></itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Features/y2005/m07/d18/h18/dj.mwuhgyyh.mp3" length="17483726" type="" />
<guid>http://66.186.18.80/podcast/mp3/ls/ls050717le_Show.mp3</guid>
<pubDate>Sun, 17 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category>
<itunes:category text="Comedy" />
<itunes:category text="Comedy" />
<itunes:duration>48:33</itunes:duration>
<itunes:block>no</itunes:block>
<itunes:isClosedCaptioned>no</itunes:isClosedCaptioned>
<itunes:explicit>clean</itunes:explicit>
</item>
<item>
<title>le Show</title>
<itunes:author>Harry Shearer</itunes:author>
<enclosure url="http://a1.phobos.apple.com/Music/y2005/m07/d12/h14/axebmlyj.mp3" length="16541124" type="" />
<guid>http://66.186.18.80/podcast/mp3/ls/ls050710le_Show.mp3</guid>
<pubDate>Sun, 10 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category>
<itunes:category text="Comedy" />
<itunes:category text="Comedy" />
<itunes:duration>45:56</itunes:duration>
<itunes:keywords></itunes:keywords> <itunes:keywords></itunes:keywords>
</item> </item>
</channel> </channel>
</rss> </rss>