Honor mrss' isDefault attribute

This commit is contained in:
Cj Malone 2016-07-25 10:05:44 +01:00
parent d4d696d83a
commit 8a7029ed78
1 changed files with 11 additions and 2 deletions

View File

@ -23,6 +23,7 @@ public class NSMedia extends Namespace {
private static final String SIZE = "fileSize";
private static final String MIME_TYPE = "type";
private static final String DURATION = "duration";
private static final String DEFAULT = "isDefault";
@Override
public SyndElement handleElementStart(String localName, HandlerState state,
@ -30,14 +31,21 @@ public class NSMedia extends Namespace {
if (CONTENT.equals(localName)) {
String url = attributes.getValue(DOWNLOAD_URL);
String type = attributes.getValue(MIME_TYPE);
String defaultStr = attributes.getValue(DEFAULT);
boolean validType;
boolean isDefault = false;
if (SyndTypeUtils.enclosureTypeValid(type)) {
validType = true;
} else {
type = SyndTypeUtils.getValidMimeTypeFromUrl(url);
validType = type != null;
}
if (state.getCurrentItem() != null && state.getCurrentItem().getMedia() == null &&
if (defaultStr == "true")
isDefault = true;
if (state.getCurrentItem() != null &&
(state.getCurrentItem().getMedia() == null || isDefault) &&
url != null && validType) {
long size = 0;
String sizeStr = attributes.getValue(SIZE);
@ -71,4 +79,5 @@ public class NSMedia extends Namespace {
public void handleElementEnd(String localName, HandlerState state) {
}
}
}