From a83d0209449949735954b6eecc50027f64faefd4 Mon Sep 17 00:00:00 2001 From: skil3z <43092256+skil3z@users.noreply.github.com> Date: Sun, 9 Sep 2018 12:53:10 +0300 Subject: [PATCH] Accommodate time formatting for different countries If there's a . in the time format, this detects it and uses is instead of : This removes errors and lag related to "Could not get duration" while using NewPipe in countries with official time formatting with . (dot) instead of : (punctuation colon) Tested to compile and work on real device --- .../youtube/linkHandler/YoutubeParsingHelper.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeParsingHelper.java index fca0584ca..fc16333f2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeParsingHelper.java @@ -30,7 +30,17 @@ public class YoutubeParsingHelper { public static long parseDurationString(String input) throws ParsingException, NumberFormatException { - String[] splitInput = input.split(":"); + + String[] splitInput; + + // If time separator : is not detected, try . instead + + if (input.contains(":")) { + splitInput = input.split(":"); + } else { + splitInput = input.split("\\."); + } + String days = "0"; String hours = "0"; String minutes = "0";