summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAnderson Mesquita <andersonvom@gmail.com>2019-05-04 13:10:23 -0400
committerAnderson Mesquita <andersonvom@gmail.com>2019-05-05 00:04:06 -0400
commitfb3bfa9f8018bd89b97fd0e0c53ea4fab1687aa2 (patch)
treefcd876a65ad60ae1fd7b2c719aea8830a124286b /core
parent9b41139709656d0e0a650acd0a17a67eac987ab7 (diff)
downloadAntennaPod-fb3bfa9f8018bd89b97fd0e0c53ea4fab1687aa2.zip
Handle iTunes single-number duration format
Apple says this [1] about the `<itunes:duration>` tag: If you specify a single number as a value (without colons), Apple Podcasts displays the value as seconds. This commit makes it also handle this single-number format. Closes: #3024 [1]: https://help.apple.com/itc/podcasts_connect/#/itcb54353390
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/syndication/parsers/DurationParser.java4
-rw-r--r--core/src/test/java/de/danoeh/antennapod/core/syndication/parsers/DurationParserTest.java7
2 files changed, 10 insertions, 1 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/parsers/DurationParser.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/parsers/DurationParser.java
index e14866b4e..8b036c6a9 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/syndication/parsers/DurationParser.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/parsers/DurationParser.java
@@ -8,7 +8,9 @@ public class DurationParser {
public static long inMillis(String durationStr) throws NumberFormatException {
String[] parts = durationStr.trim().split(":");
- if (parts.length == 2) {
+ if (parts.length == 1) {
+ return toMillis(parts[0]);
+ } else if (parts.length == 2) {
return toMillis("0", parts[0], parts[1]);
} else if (parts.length == 3) {
return toMillis(parts[0], parts[1], parts[2]);
diff --git a/core/src/test/java/de/danoeh/antennapod/core/syndication/parsers/DurationParserTest.java b/core/src/test/java/de/danoeh/antennapod/core/syndication/parsers/DurationParserTest.java
index b73916b24..e7c861969 100644
--- a/core/src/test/java/de/danoeh/antennapod/core/syndication/parsers/DurationParserTest.java
+++ b/core/src/test/java/de/danoeh/antennapod/core/syndication/parsers/DurationParserTest.java
@@ -17,6 +17,13 @@ public class DurationParserTest {
}
@Test
+ public void testSingleNumberDurationInMillis() {
+ int twoHoursInSeconds = 2 * 60 * 60;
+ long duration = DurationParser.inMillis(String.valueOf(twoHoursInSeconds));
+ assertEquals(2 * hours, duration);
+ }
+
+ @Test
public void testMinuteSecondDurationInMillis() {
long duration = DurationParser.inMillis("05:10");
assertEquals(5 * minutes + 10 * seconds, duration);