From b63ae934957ac2e6789309945e1b93654af0cefa Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 15 Jun 2020 11:27:44 +0200 Subject: [PATCH] Added a comment and fixed a "typo" in the method parseDurationString replacing Long with Integer. These are not the droids you are looking for wb9688 :grin: --- .../services/youtube/YoutubeParsingHelper.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 748766c10..9d360d83e 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 @@ -108,7 +108,12 @@ public class YoutubeParsingHelper { return host.equalsIgnoreCase("invidio.us") || host.equalsIgnoreCase("dev.invidio.us") || host.equalsIgnoreCase("www.invidio.us") || host.equalsIgnoreCase("invidious.snopyta.org") || host.equalsIgnoreCase("de.invidious.snopyta.org") || host.equalsIgnoreCase("fi.invidious.snopyta.org") || host.equalsIgnoreCase("vid.wxzm.sx") || host.equalsIgnoreCase("invidious.kabi.tk") || host.equalsIgnoreCase("invidiou.sh") || host.equalsIgnoreCase("www.invidiou.sh") || host.equalsIgnoreCase("no.invidiou.sh") || host.equalsIgnoreCase("invidious.enkirton.net") || host.equalsIgnoreCase("tube.poal.co") || host.equalsIgnoreCase("invidious.13ad.de") || host.equalsIgnoreCase("yt.elukerio.org"); } - public static long parseDurationString(String input) + /** + * Parses the duration string of the video expecting ":" or "." as seperators + * @return the duration in seconds + * @throws ParsingException when more than 3 seperators are found + */ + public static int parseDurationString(String input) throws ParsingException, NumberFormatException { // If time separator : is not detected, try . instead final String[] splitInput = input.contains(":") @@ -143,10 +148,10 @@ public class YoutubeParsingHelper { 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 - + Long.parseLong(Utils.removeNonDigitCharacters(seconds)); + return ((Integer.parseInt(Utils.removeNonDigitCharacters(days)) * 24 + + Integer.parseInt(Utils.removeNonDigitCharacters(hours))) * 60 + + Integer.parseInt(Utils.removeNonDigitCharacters(minutes))) * 60 + + Integer.parseInt(Utils.removeNonDigitCharacters(seconds)); } public static String getFeedUrlFrom(final String channelIdOrUser) {