Merge remote-tracking branch 'origin/pr/790'

master
Andrew DeMaria 6 years ago
commit 30b767955e
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 15
      airsonic-main/src/main/java/org/airsonic/player/service/PodcastService.java

@ -422,7 +422,7 @@ public class PodcastService {
for (Element episodeElement : episodeElements) {
String title = episodeElement.getChildTextTrim("title");
String duration = getITunesElement(episodeElement, "duration");
String duration = formatDuration(getITunesElement(episodeElement, "duration"));
String description = episodeElement.getChildTextTrim("description");
if (StringUtils.isBlank(description)) {
description = getITunesElement(episodeElement, "summary");
@ -502,6 +502,19 @@ public class PodcastService {
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) {
for (Namespace ns : ITUNES_NAMESPACES) {
String value = element.getChildTextTrim(childName, ns);

Loading…
Cancel
Save