Compare commits
1 commit
master
...
ROME-244-i
Author | SHA1 | Date | |
---|---|---|---|
|
c447eda87b |
11 changed files with 1719 additions and 1665 deletions
|
@ -41,6 +41,7 @@
|
|||
package com.rometools.modules.itunes;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 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";
|
||||
private String author;
|
||||
private boolean block;
|
||||
private boolean explicit;
|
||||
private Explicit explicit;
|
||||
private URL image;
|
||||
private String[] keywords;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public boolean getExplicit() {
|
||||
public Explicit getExplicit() {
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public void setExplicit(final boolean explicit) {
|
||||
public void setExplicit(final Explicit explicit) {
|
||||
this.explicit = explicit;
|
||||
}
|
||||
|
||||
|
@ -245,29 +246,23 @@ public abstract class AbstractITunesObject implements ITunes, java.lang.Cloneabl
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("[");
|
||||
sb.append(" Author: ");
|
||||
sb.append(getAuthor());
|
||||
sb.append(" Block: ");
|
||||
sb.append(getBlock());
|
||||
sb.append(" Explicit: ");
|
||||
sb.append(getExplicit());
|
||||
sb.append(" Image: ");
|
||||
sb.append(getImage());
|
||||
sb.append(" Keywords: ");
|
||||
|
||||
if (getKeywords() != null) {
|
||||
for (int i = 0; i < keywords.length; i++) {
|
||||
sb.append("'" + getKeywords()[i] + "'");
|
||||
}
|
||||
}
|
||||
|
||||
sb.append(" Subtitle: ");
|
||||
sb.append(getSubtitle());
|
||||
sb.append(" Summary: ");
|
||||
sb.append(getSummary());
|
||||
sb.append("]");
|
||||
|
||||
return sb.toString();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("AbstractITunesObject [author=");
|
||||
builder.append(author);
|
||||
builder.append(", block=");
|
||||
builder.append(block);
|
||||
builder.append(", explicit=");
|
||||
builder.append(explicit);
|
||||
builder.append(", image=");
|
||||
builder.append(image);
|
||||
builder.append(", keywords=");
|
||||
builder.append(Arrays.toString(keywords));
|
||||
builder.append(", subtitle=");
|
||||
builder.append(subtitle);
|
||||
builder.append(", summary=");
|
||||
builder.append(summary);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -52,6 +52,15 @@ import com.rometools.modules.itunes.types.Duration;
|
|||
*/
|
||||
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
|
||||
*
|
||||
|
@ -66,9 +75,9 @@ public interface EntryInformation extends ITunes {
|
|||
*/
|
||||
public void setDuration(Duration duration);
|
||||
|
||||
public boolean getClosedCaptioned();
|
||||
public ClosedCaptioned getClosedCaptioned();
|
||||
|
||||
public void setClosedCaptioned(boolean closedCaptioned);
|
||||
public void setClosedCaptioned(ClosedCaptioned closedCaptioned);
|
||||
|
||||
public Integer getOrder();
|
||||
|
||||
|
|
|
@ -40,14 +40,14 @@
|
|||
*/
|
||||
package com.rometools.modules.itunes;
|
||||
|
||||
import com.rometools.modules.itunes.types.Duration;
|
||||
import com.rometools.rome.feed.CopyFrom;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import com.rometools.modules.itunes.types.Duration;
|
||||
import com.rometools.rome.feed.CopyFrom;
|
||||
|
||||
/**
|
||||
* 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 Duration duration;
|
||||
private boolean closedCaptioned;
|
||||
private ClosedCaptioned closedCaptioned;
|
||||
private Integer order;
|
||||
|
||||
/**
|
||||
|
@ -94,12 +94,12 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean getClosedCaptioned() {
|
||||
public ClosedCaptioned getClosedCaptioned() {
|
||||
return closedCaptioned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClosedCaptioned(boolean closedCaptioned) {
|
||||
public void setClosedCaptioned(final ClosedCaptioned closedCaptioned) {
|
||||
this.closedCaptioned = closedCaptioned;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setOrder(Integer order) {
|
||||
public void setOrder(final Integer order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
|
@ -163,16 +163,15 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("[");
|
||||
sb.append(" duration: ");
|
||||
sb.append(getDuration());
|
||||
sb.append(" closedCaptioned: ");
|
||||
sb.append(getClosedCaptioned());
|
||||
sb.append(" order: ");
|
||||
sb.append(getOrder());
|
||||
sb.append("]");
|
||||
sb.append(super.toString());
|
||||
|
||||
return sb.toString();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("EntryInformationImpl [duration=");
|
||||
builder.append(duration);
|
||||
builder.append(", closedCaptioned=");
|
||||
builder.append(closedCaptioned);
|
||||
builder.append(", order=");
|
||||
builder.append(order);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,13 +67,13 @@ public interface FeedInformation extends ITunes {
|
|||
*/
|
||||
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.
|
||||
|
|
|
@ -67,8 +67,8 @@ public class FeedInformationImpl extends AbstractITunesObject implements FeedInf
|
|||
private String ownerName;
|
||||
private String ownerEmailAddress;
|
||||
private List<Category> categories;
|
||||
private boolean complete;
|
||||
private String newFeedUrl;
|
||||
private Boolean complete;
|
||||
private URL newFeedUrl;
|
||||
|
||||
/**
|
||||
* Creates a new instance of FeedInformationImpl
|
||||
|
@ -97,22 +97,22 @@ public class FeedInformationImpl extends AbstractITunesObject implements FeedInf
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean getComplete() {
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComplete(boolean complete) {
|
||||
public void setComplete(final Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewFeedUrl() {
|
||||
public URL getNewFeedUrl() {
|
||||
return newFeedUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewFeedUrl(String newFeedUrl) {
|
||||
public void setNewFeedUrl(final URL newFeedUrl) {
|
||||
this.newFeedUrl = newFeedUrl;
|
||||
}
|
||||
|
||||
|
@ -209,20 +209,19 @@ public class FeedInformationImpl extends AbstractITunesObject implements FeedInf
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("[");
|
||||
sb.append(" email: ");
|
||||
sb.append(getOwnerEmailAddress());
|
||||
sb.append(" name: ");
|
||||
sb.append(getOwnerName());
|
||||
sb.append(" categories: ");
|
||||
sb.append(getCategories());
|
||||
sb.append(" complete: ");
|
||||
sb.append(getComplete());
|
||||
sb.append(" newFeedUrl: ");
|
||||
sb.append(getNewFeedUrl());
|
||||
sb.append("]");
|
||||
sb.append(super.toString());
|
||||
|
||||
return sb.toString();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("FeedInformationImpl [ownerName=");
|
||||
builder.append(ownerName);
|
||||
builder.append(", ownerEmailAddress=");
|
||||
builder.append(ownerEmailAddress);
|
||||
builder.append(", categories=");
|
||||
builder.append(categories);
|
||||
builder.append(", complete=");
|
||||
builder.append(complete);
|
||||
builder.append(", newFeedUrl=");
|
||||
builder.append(newFeedUrl);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -52,6 +52,15 @@ import java.net.URL;
|
|||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -83,18 +92,18 @@ public interface ITunes extends Module {
|
|||
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();
|
||||
|
||||
|
|
|
@ -90,10 +90,10 @@ public class ITunesGenerator implements ModuleGenerator {
|
|||
if (itunes instanceof FeedInformationImpl) {
|
||||
// Do Channel Specific Stuff.
|
||||
final FeedInformationImpl info = (FeedInformationImpl) itunes;
|
||||
|
||||
final Element owner = generateSimpleElement("owner", "");
|
||||
final Element email = generateSimpleElement("email", info.getOwnerEmailAddress());
|
||||
owner.addContent(email);
|
||||
|
||||
final Element name = generateSimpleElement("name", info.getOwnerName());
|
||||
owner.addContent(name);
|
||||
element.addContent(owner);
|
||||
|
@ -113,12 +113,16 @@ public class ITunesGenerator implements ModuleGenerator {
|
|||
element.addContent(category);
|
||||
}
|
||||
|
||||
if (info.getComplete()) {
|
||||
element.addContent(generateSimpleElement("complete", "yes"));
|
||||
if (info.getComplete() != null) {
|
||||
if (info.getComplete()) {
|
||||
element.addContent(generateSimpleElement("complete", "yes"));
|
||||
} else {
|
||||
element.addContent(generateSimpleElement("complete", "no"));
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -127,8 +131,8 @@ public class ITunesGenerator implements ModuleGenerator {
|
|||
if (info.getDuration() != null) {
|
||||
element.addContent(generateSimpleElement("duration", info.getDuration().toString()));
|
||||
}
|
||||
if (info.getClosedCaptioned()) {
|
||||
element.addContent(generateSimpleElement("isClosedCaptioned", "yes"));
|
||||
if (info.getClosedCaptioned() != null) {
|
||||
element.addContent(generateSimpleElement("isClosedCaptioned", info.getClosedCaptioned().name()));
|
||||
}
|
||||
if (info.getOrder() != null) {
|
||||
element.addContent(generateSimpleElement("order", info.getOrder().toString()));
|
||||
|
@ -143,10 +147,8 @@ public class ITunesGenerator implements ModuleGenerator {
|
|||
element.addContent(generateSimpleElement("block", ""));
|
||||
}
|
||||
|
||||
if (itunes.getExplicit()) {
|
||||
element.addContent(generateSimpleElement("explicit", "yes"));
|
||||
} else {
|
||||
element.addContent(generateSimpleElement("explicit", "no"));
|
||||
if (itunes.getExplicit() != null) {
|
||||
element.addContent(generateSimpleElement("explicit", itunes.getExplicit().name()));
|
||||
}
|
||||
|
||||
if (itunes.getImage() != null) {
|
||||
|
|
|
@ -54,13 +54,17 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.rometools.modules.itunes.AbstractITunesObject;
|
||||
import com.rometools.modules.itunes.EntryInformation;
|
||||
import com.rometools.modules.itunes.EntryInformationImpl;
|
||||
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.Duration;
|
||||
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.WireFeedParser;
|
||||
import com.rometools.utils.Integers;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.10 $
|
||||
|
@ -70,12 +74,23 @@ public class ITunesParser implements ModuleParser {
|
|||
|
||||
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 */
|
||||
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) {
|
||||
}
|
||||
|
||||
|
@ -85,7 +100,7 @@ public class ITunesParser implements ModuleParser {
|
|||
}
|
||||
|
||||
@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;
|
||||
|
||||
if (element.getName().equals("channel")) {
|
||||
|
@ -135,7 +150,11 @@ public class ITunesParser implements ModuleParser {
|
|||
|
||||
final Element newFeedUrl = element.getChild("new-feed-url", ns);
|
||||
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")) {
|
||||
|
@ -145,16 +164,15 @@ public class ITunesParser implements ModuleParser {
|
|||
// Now I am going to get the item specific tags
|
||||
|
||||
final Element duration = element.getChild("duration", ns);
|
||||
|
||||
if (duration != null && duration.getValue() != null) {
|
||||
final Duration dur = new Duration(duration.getValue().trim());
|
||||
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")) {
|
||||
entryInfo.setClosedCaptioned(true);
|
||||
if (isClosedCaptioned != null && isClosedCaptioned.getValue() != null ) {
|
||||
entryInfo.setClosedCaptioned(EntryInformation.ClosedCaptioned.valueOf(isClosedCaptioned.getTextTrim().toLowerCase()));
|
||||
}
|
||||
|
||||
final Element order = element.getChild("order", ns);
|
||||
|
@ -175,13 +193,13 @@ public class ITunesParser implements ModuleParser {
|
|||
final Element block = element.getChild("block", ns);
|
||||
|
||||
if (block != null) {
|
||||
module.setBlock(true);
|
||||
module.setBlock("yes".equals(block.getTextTrim().toLowerCase()));
|
||||
}
|
||||
|
||||
final Element explicit = element.getChild("explicit", ns);
|
||||
|
||||
if (explicit != null && explicit.getValue() != null && explicit.getValue().trim().equalsIgnoreCase("yes")) {
|
||||
module.setExplicit(true);
|
||||
if (explicit != null && explicit.getValue() != null) {
|
||||
module.setExplicit(ITunes.Explicit.valueOf(explicit.getTextTrim().toLowerCase()));
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return module;
|
||||
|
|
|
@ -47,12 +47,11 @@ import org.jdom2.Namespace;
|
|||
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
|
||||
*/
|
||||
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 */
|
||||
public ITunesParserOldNamespace() {
|
||||
super();
|
||||
super.ns = Namespace.getNamespace(URI);
|
||||
super(Namespace.getNamespace(URI));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,26 +7,27 @@
|
|||
package com.rometools.modules.itunes;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.rometools.modules.AbstractTestCase;
|
||||
import com.rometools.modules.itunes.AbstractITunesObject;
|
||||
import com.rometools.modules.itunes.EntryInformationImpl;
|
||||
import com.rometools.modules.itunes.FeedInformationImpl;
|
||||
import com.rometools.modules.itunes.EntryInformation.ClosedCaptioned;
|
||||
import com.rometools.modules.itunes.ITunes.Explicit;
|
||||
import com.rometools.modules.itunes.io.ITunesGenerator;
|
||||
import com.rometools.rome.feed.module.Module;
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
import com.rometools.rome.feed.synd.SyndFeed;
|
||||
import com.rometools.rome.io.FeedException;
|
||||
import com.rometools.rome.io.SyndFeedInput;
|
||||
import com.rometools.rome.io.XmlReader;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cooper
|
||||
|
@ -34,6 +35,7 @@ import com.rometools.rome.io.XmlReader;
|
|||
public class ITunesParserTest extends AbstractTestCase {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ITunesParserTest.class);
|
||||
private static final int itemCountInLeShowFeed = 4;
|
||||
|
||||
public ITunesParserTest(final String testName) {
|
||||
super(testName);
|
||||
|
@ -81,8 +83,9 @@ public class ITunesParserTest extends AbstractTestCase {
|
|||
"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.",
|
||||
feedInfo.getSummary());
|
||||
assertEquals(true, feedInfo.getComplete());
|
||||
assertEquals("http://example.org", feedInfo.getNewFeedUrl());
|
||||
assertEquals("complete", Boolean.TRUE, feedInfo.getComplete());
|
||||
assertEquals("new-feed-url", "http://newlocation.com/example.rss", feedInfo.getNewFeedUrl().toExternalForm());
|
||||
assertFalse("block", feedInfo.getBlock());
|
||||
|
||||
List<SyndEntry> entries = syndfeed.getEntries();
|
||||
Iterator<SyndEntry> it = entries.iterator();
|
||||
|
@ -103,6 +106,7 @@ public class ITunesParserTest extends AbstractTestCase {
|
|||
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
|
||||
LOG.debug("{}", entryInfo.getDuration());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,8 +120,123 @@ public class ITunesParserTest extends AbstractTestCase {
|
|||
SyndEntry entry = syndfeed.getEntries().get(0);
|
||||
|
||||
EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
|
||||
assertEquals(true, entryInfo.getClosedCaptioned());
|
||||
assertEquals(ClosedCaptioned.yes, entryInfo.getClosedCaptioned());
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,189 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
|
||||
<channel>
|
||||
<title>KCRW's Le Show</title>
|
||||
<itunes:author>Harry Shearer</itunes:author>
|
||||
<link>http://www.kcrw.com/show/ls</link>
|
||||
<description>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.</description>
|
||||
<itunes:subtitle>An hour'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>
|
||||
<channel>
|
||||
<title>KCRW's Le Show</title>
|
||||
<itunes:author>Harry Shearer</itunes:author>
|
||||
<link>http://www.kcrw.com/show/ls</link>
|
||||
<description>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.</description>
|
||||
<itunes:subtitle>An hour'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:complete>yes</itunes:complete>
|
||||
<itunes:new-feed-url>http://example.org</itunes:new-feed-url>
|
||||
<language>en</language>
|
||||
|
||||
<copyright>KCRW 2005</copyright>
|
||||
|
||||
<itunes:owner>
|
||||
<itunes:name>Harry Shearer</itunes:name>
|
||||
<itunes:email></itunes:email>
|
||||
</itunes:owner>
|
||||
|
||||
<itunes:image rel="image" href="http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg">KCRW's Le Show</itunes:image>
|
||||
|
||||
|
||||
<category>Comedy</category>
|
||||
|
||||
|
||||
<itunes:category text="Comedy"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<itunes:category text="Comedy"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<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/m08/d01/h14/eosmhmit.mp3" length="16770270" type=""/>
|
||||
<guid>http://66.186.18.80/podcast/mp3/ls/ls050731le_Show.mp3</guid>
|
||||
|
||||
<pubDate>Sun, 31 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>46:34</itunes:duration>
|
||||
|
||||
<itunes:keywords></itunes:keywords>
|
||||
<itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned>
|
||||
<itunes:order>2</itunes:order>
|
||||
<itunes:image href="http://example.org/image.png"></itunes:image>
|
||||
</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>
|
||||
<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/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:explicit>no</itunes:explicit>
|
||||
|
||||
<itunes:duration>45:56</itunes:duration>
|
||||
|
||||
<itunes:keywords></itunes:keywords>
|
||||
</item>
|
||||
|
||||
|
||||
<itunes:new-feed-url>http://newlocation.com/example.rss</itunes:new-feed-url>
|
||||
<language>en</language>
|
||||
<copyright>KCRW 2005</copyright>
|
||||
<itunes:owner>
|
||||
<itunes:name>Harry Shearer</itunes:name>
|
||||
<itunes:email></itunes:email>
|
||||
</itunes:owner>
|
||||
<itunes:image rel="image" href="http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg">KCRW's Le Show</itunes:image>
|
||||
<category>Comedy</category>
|
||||
<itunes:category text="Comedy" />
|
||||
<itunes:category text="Comedy" />
|
||||
<itunes:block>no</itunes:block>
|
||||
<itunes:explicit>yes</itunes:explicit>
|
||||
<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/m08/d01/h14/eosmhmit.mp3" length="16770270" type="" />
|
||||
<guid>http://66.186.18.80/podcast/mp3/ls/ls050731le_Show.mp3</guid>
|
||||
<pubDate>Sun, 31 Jul 2005 16:00:00 GMT</pubDate>
|
||||
<category>Comedy</category>
|
||||
<itunes:category text="Comedy" />
|
||||
<itunes:category text="Comedy" />
|
||||
<itunes:explicit>yes</itunes:explicit>
|
||||
<itunes:duration>46:34</itunes:duration>
|
||||
<itunes:keywords></itunes:keywords>
|
||||
<itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned>
|
||||
<itunes:order>2</itunes:order>
|
||||
<itunes:image rel="image" href="http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg">KCRW's Le Show</itunes:image>
|
||||
<itunes:block>yes</itunes:block>
|
||||
</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: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>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
|
|
Loading…
Reference in a new issue