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
This commit is contained in:
parent
9b41139709
commit
fb3bfa9f80
|
@ -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]);
|
||||
|
|
|
@ -16,6 +16,13 @@ public class DurationParserTest {
|
|||
assertEquals(45 * seconds, duration);
|
||||
}
|
||||
|
||||
@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");
|
||||
|
|
Loading…
Reference in New Issue