From b63ae934957ac2e6789309945e1b93654af0cefa Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 15 Jun 2020 11:27:44 +0200 Subject: [PATCH 1/2] 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 748766c104..9d360d83ec 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 static boolean isInvidioURL(URL url) { 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 static long parseDurationString(String input) 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) { From 576754982e3d99a4336d77cf8f2a4afe1e649768 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 27 Jun 2020 11:35:01 +0200 Subject: [PATCH 2/2] Update extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java Co-authored-by: Tobias Groza --- .../extractor/services/youtube/YoutubeParsingHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9d360d83ec..1fd76c6276 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 @@ -113,7 +113,7 @@ public static boolean isInvidioURL(URL url) { * @return the duration in seconds * @throws ParsingException when more than 3 seperators are found */ - public static int parseDurationString(String input) + public static int parseDurationString(final String input) throws ParsingException, NumberFormatException { // If time separator : is not detected, try . instead final String[] splitInput = input.contains(":")