@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 ")); }
public static int parseDurationString(final String input) throws ParsingException, NumberFormatException { final String[] splitInput = input.contains(":") ? input.split(":") : input.split("\\."); String days = "0"; String hours = "0"; String minutes = "0"; final String seconds; switch (splitInput.length) { case 4: days = splitInput[0]; hours = splitInput[1]; minutes = splitInput[2]; seconds = splitInput[3]; break; case 3: hours = splitInput[0]; minutes = splitInput[1]; seconds = splitInput[2]; break; case 2: minutes = splitInput[0]; seconds = splitInput[1]; break; case 1: seconds = splitInput[0]; break; default: throw new ParsingException("Error duration string with unknown format: " + input); } return ((Integer.parseInt(Utils.removeNonDigitCharacters(days)) * 24 + Integer.parseInt(Utils.removeNonDigitCharacters(hours))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(minutes))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(seconds)); }
YoutubeParsingHelper { public static int parseDurationString(final String input) throws ParsingException, NumberFormatException { final String[] splitInput = input.contains(":") ? input.split(":") : input.split("\\."); String days = "0"; String hours = "0"; String minutes = "0"; final String seconds; switch (splitInput.length) { case 4: days = splitInput[0]; hours = splitInput[1]; minutes = splitInput[2]; seconds = splitInput[3]; break; case 3: hours = splitInput[0]; minutes = splitInput[1]; seconds = splitInput[2]; break; case 2: minutes = splitInput[0]; seconds = splitInput[1]; break; case 1: seconds = splitInput[0]; break; default: throw new ParsingException("Error duration string with unknown format: " + input); } return ((Integer.parseInt(Utils.removeNonDigitCharacters(days)) * 24 + Integer.parseInt(Utils.removeNonDigitCharacters(hours))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(minutes))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(seconds)); } }
YoutubeParsingHelper { public static int parseDurationString(final String input) throws ParsingException, NumberFormatException { final String[] splitInput = input.contains(":") ? input.split(":") : input.split("\\."); String days = "0"; String hours = "0"; String minutes = "0"; final String seconds; switch (splitInput.length) { case 4: days = splitInput[0]; hours = splitInput[1]; minutes = splitInput[2]; seconds = splitInput[3]; break; case 3: hours = splitInput[0]; minutes = splitInput[1]; seconds = splitInput[2]; break; case 2: minutes = splitInput[0]; seconds = splitInput[1]; break; case 1: seconds = splitInput[0]; break; default: throw new ParsingException("Error duration string with unknown format: " + input); } return ((Integer.parseInt(Utils.removeNonDigitCharacters(days)) * 24 + Integer.parseInt(Utils.removeNonDigitCharacters(hours))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(minutes))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(seconds)); } private  YoutubeParsingHelper(); }
YoutubeParsingHelper { public static int parseDurationString(final String input) throws ParsingException, NumberFormatException { final String[] splitInput = input.contains(":") ? input.split(":") : input.split("\\."); String days = "0"; String hours = "0"; String minutes = "0"; final String seconds; switch (splitInput.length) { case 4: days = splitInput[0]; hours = splitInput[1]; minutes = splitInput[2]; seconds = splitInput[3]; break; case 3: hours = splitInput[0]; minutes = splitInput[1]; seconds = splitInput[2]; break; case 2: minutes = splitInput[0]; seconds = splitInput[1]; break; case 1: seconds = splitInput[0]; break; default: throw new ParsingException("Error duration string with unknown format: " + input); } return ((Integer.parseInt(Utils.removeNonDigitCharacters(days)) * 24 + Integer.parseInt(Utils.removeNonDigitCharacters(hours))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(minutes))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(seconds)); } private  YoutubeParsingHelper(); static Document parseAndCheckPage(final String url, final Response response); static boolean isYoutubeURL(URL url); static boolean isYoutubeServiceURL(URL url); static boolean isHooktubeURL(URL url); static boolean isInvidioURL(URL url); static int parseDurationString(final String input); static String getFeedUrlFrom(final String channelIdOrUser); static Calendar parseDateFrom(String textualUploadDate); static JsonObject getInitialData(String html); static boolean isHardcodedClientVersionValid(); static String getClientVersion(); static String getKey(); static boolean areHardcodedYoutubeMusicKeysValid(); static String[] getYoutubeMusicKeys(); static String getUrlFromNavigationEndpoint(JsonObject navigationEndpoint); static String getTextFromObject(JsonObject textObject, boolean html); static String getTextFromObject(JsonObject textObject); static String fixThumbnailUrl(String thumbnailUrl); static String getValidJsonResponseBody(final Response response); static JsonArray getJsonResponse(final String url, final Localization localization); static void defaultAlertsCheck(final JsonObject initialData); }
YoutubeParsingHelper { public static int parseDurationString(final String input) throws ParsingException, NumberFormatException { final String[] splitInput = input.contains(":") ? input.split(":") : input.split("\\."); String days = "0"; String hours = "0"; String minutes = "0"; final String seconds; switch (splitInput.length) { case 4: days = splitInput[0]; hours = splitInput[1]; minutes = splitInput[2]; seconds = splitInput[3]; break; case 3: hours = splitInput[0]; minutes = splitInput[1]; seconds = splitInput[2]; break; case 2: minutes = splitInput[0]; seconds = splitInput[1]; break; case 1: seconds = splitInput[0]; break; default: throw new ParsingException("Error duration string with unknown format: " + input); } return ((Integer.parseInt(Utils.removeNonDigitCharacters(days)) * 24 + Integer.parseInt(Utils.removeNonDigitCharacters(hours))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(minutes))) * 60 + Integer.parseInt(Utils.removeNonDigitCharacters(seconds)); } private  YoutubeParsingHelper(); static Document parseAndCheckPage(final String url, final Response response); static boolean isYoutubeURL(URL url); static boolean isYoutubeServiceURL(URL url); static boolean isHooktubeURL(URL url); static boolean isInvidioURL(URL url); static int parseDurationString(final String input); static String getFeedUrlFrom(final String channelIdOrUser); static Calendar parseDateFrom(String textualUploadDate); static JsonObject getInitialData(String html); static boolean isHardcodedClientVersionValid(); static String getClientVersion(); static String getKey(); static boolean areHardcodedYoutubeMusicKeysValid(); static String[] getYoutubeMusicKeys(); static String getUrlFromNavigationEndpoint(JsonObject navigationEndpoint); static String getTextFromObject(JsonObject textObject, boolean html); static String getTextFromObject(JsonObject textObject); static String fixThumbnailUrl(String thumbnailUrl); static String getValidJsonResponseBody(final Response response); static JsonArray getJsonResponse(final String url, final Localization localization); static void defaultAlertsCheck(final JsonObject initialData); final static String BASE_YOUTUBE_INTENT_URL; }