Merge remote-tracking branch 'origin/pr/790'
This commit is contained in:
@@ -422,7 +422,7 @@ public class PodcastService {
|
|||||||
for (Element episodeElement : episodeElements) {
|
for (Element episodeElement : episodeElements) {
|
||||||
|
|
||||||
String title = episodeElement.getChildTextTrim("title");
|
String title = episodeElement.getChildTextTrim("title");
|
||||||
String duration = getITunesElement(episodeElement, "duration");
|
String duration = formatDuration(getITunesElement(episodeElement, "duration"));
|
||||||
String description = episodeElement.getChildTextTrim("description");
|
String description = episodeElement.getChildTextTrim("description");
|
||||||
if (StringUtils.isBlank(description)) {
|
if (StringUtils.isBlank(description)) {
|
||||||
description = getITunesElement(episodeElement, "summary");
|
description = getITunesElement(episodeElement, "summary");
|
||||||
@@ -502,6 +502,19 @@ public class PodcastService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String formatDuration(String duration) {
|
||||||
|
if (duration == null) return null;
|
||||||
|
if (duration.matches("^\\d+$")) {
|
||||||
|
long seconds = Long.valueOf(duration);
|
||||||
|
if (seconds >= 3600)
|
||||||
|
return String.format("%02d:%02d:%02d", seconds / 3600, seconds / 60, seconds % 60);
|
||||||
|
else
|
||||||
|
return String.format("%02d:%02d", seconds / 60, seconds % 60);
|
||||||
|
} else {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getITunesElement(Element element, String childName) {
|
private String getITunesElement(Element element, String childName) {
|
||||||
for (Namespace ns : ITUNES_NAMESPACES) {
|
for (Namespace ns : ITUNES_NAMESPACES) {
|
||||||
String value = element.getChildTextTrim(childName, ns);
|
String value = element.getChildTextTrim(childName, ns);
|
||||||
|
|||||||
Reference in New Issue
Block a user