diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java index 6df9b4b87..748766c10 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java @@ -142,9 +142,10 @@ public class YoutubeParsingHelper { default: throw new ParsingException("Error duration string with unknown format: " + input); } - return ((((Long.parseLong(Utils.removeNonDigitCharacters(days)) * 24) - + Long.parseLong(Utils.removeNonDigitCharacters(hours)) * 60) - + Long.parseLong(Utils.removeNonDigitCharacters(minutes))) * 60) + + return ((Long.parseLong(Utils.removeNonDigitCharacters(days)) * 24 + + Long.parseLong(Utils.removeNonDigitCharacters(hours))) * 60 + + Long.parseLong(Utils.removeNonDigitCharacters(minutes))) * 60 + Long.parseLong(Utils.removeNonDigitCharacters(seconds)); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java index 0a3e007fc..34a300876 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java @@ -5,9 +5,11 @@ import org.junit.Test; import org.schabi.newpipe.DownloaderTestImpl; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.exceptions.ParsingException; import java.io.IOException; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class YoutubeParsingHelperTest { @@ -27,4 +29,11 @@ public class YoutubeParsingHelperTest { assertTrue("Hardcoded YouTube Music keys are not valid anymore", YoutubeParsingHelper.areHardcodedYoutubeMusicKeysValid()); } + + @Test + public void testParseDurationString() throws ParsingException { + assertEquals(1162567, YoutubeParsingHelper.parseDurationString("12:34:56:07")); + assertEquals(4445767, YoutubeParsingHelper.parseDurationString("1,234:56:07")); + assertEquals(754, YoutubeParsingHelper.parseDurationString("12:34 ")); + } }