Merge pull request #34 from mishako/itunes-order-and-cc
Support for itunes:order and itunes:isClosedCaptioned (fixed). Thanks Misha!
This commit is contained in:
commit
07b071e07d
6 changed files with 71 additions and 1 deletions
|
@ -66,4 +66,11 @@ public interface EntryInformation extends ITunes {
|
||||||
*/
|
*/
|
||||||
public void setDuration(Duration duration);
|
public void setDuration(Duration duration);
|
||||||
|
|
||||||
|
public boolean getClosedCaptioned();
|
||||||
|
|
||||||
|
public void setClosedCaptioned(boolean closedCaptioned);
|
||||||
|
|
||||||
|
public Integer getOrder();
|
||||||
|
|
||||||
|
public void setOrder(Integer order);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Duration duration;
|
private Duration duration;
|
||||||
|
private boolean closedCaptioned;
|
||||||
|
private Integer order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of EntryInformationImpl
|
* Creates a new instance of EntryInformationImpl
|
||||||
|
@ -82,6 +84,26 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getClosedCaptioned() {
|
||||||
|
return closedCaptioned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setClosedCaptioned(boolean closedCaptioned) {
|
||||||
|
this.closedCaptioned = closedCaptioned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getOrder() {
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOrder(Integer order) {
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defined by the ROME module API
|
* Defined by the ROME module API
|
||||||
*
|
*
|
||||||
|
@ -105,6 +127,8 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
|
||||||
|
|
||||||
setSubtitle(info.getSubtitle());
|
setSubtitle(info.getSubtitle());
|
||||||
setSummary(info.getSummary());
|
setSummary(info.getSummary());
|
||||||
|
setClosedCaptioned(info.getClosedCaptioned());
|
||||||
|
setOrder(info.getOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,8 +147,12 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuffer sb = new StringBuffer("[");
|
final StringBuffer sb = new StringBuffer("[");
|
||||||
sb.append(" Duration: ");
|
sb.append(" duration: ");
|
||||||
sb.append(getDuration());
|
sb.append(getDuration());
|
||||||
|
sb.append(" closedCaptioned: ");
|
||||||
|
sb.append(getClosedCaptioned());
|
||||||
|
sb.append(" order: ");
|
||||||
|
sb.append(getOrder());
|
||||||
sb.append("]");
|
sb.append("]");
|
||||||
sb.append(super.toString());
|
sb.append(super.toString());
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,12 @@ 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()) {
|
||||||
|
element.addContent(generateSimpleElement("isClosedCaptioned", "yes"));
|
||||||
|
}
|
||||||
|
if (info.getOrder() != null) {
|
||||||
|
element.addContent(generateSimpleElement("order", info.getOrder().toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itunes.getAuthor() != null) {
|
if (itunes.getAuthor() != null) {
|
||||||
|
|
|
@ -151,6 +151,19 @@ public class ITunesParser implements ModuleParser {
|
||||||
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);
|
||||||
|
|
||||||
|
if (closedCaptioned != null && closedCaptioned.getValue() != null && closedCaptioned.getValue().trim().equalsIgnoreCase("yes")) {
|
||||||
|
entryInfo.setClosedCaptioned(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Element order = element.getChild("order", ns);
|
||||||
|
|
||||||
|
if (order != null && order.getValue() != null) {
|
||||||
|
final Integer o = Integer.valueOf(order.getValue().trim());
|
||||||
|
entryInfo.setOrder(o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (module != null) {
|
if (module != null) {
|
||||||
// All these are common to both Channel and Item
|
// All these are common to both Channel and Item
|
||||||
|
|
|
@ -103,4 +103,18 @@ public class ITunesParserTest extends AbstractTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of parse method, of class com.rometools.modules.itunes.io.ITunesParser.
|
||||||
|
*/
|
||||||
|
public void testParseItem() throws Exception {
|
||||||
|
File feed = new File(getTestFile("xml/leshow.xml"));
|
||||||
|
final SyndFeedInput input = new SyndFeedInput();
|
||||||
|
SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
|
||||||
|
|
||||||
|
SyndEntry entry = syndfeed.getEntries().get(0);
|
||||||
|
|
||||||
|
EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
|
||||||
|
assertEquals(true, entryInfo.getClosedCaptioned());
|
||||||
|
assertEquals(Integer.valueOf(2), entryInfo.getOrder());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,8 @@
|
||||||
<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:order>2</itunes:order>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue