From 50a4b026f8e9755b0e51eed07516babbf988e8a0 Mon Sep 17 00:00:00 2001 From: Abdu Ameen Date: Mon, 31 Jan 2022 23:52:31 -0800 Subject: [PATCH] Adding removal of the braces --- .../youtube/YoutubeThrottlingDecrypter.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java index 9b154f008..48a8f64d2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java @@ -66,7 +66,19 @@ public class YoutubeThrottlingDecrypter { private String parseDecodeFunctionName(final String playerJsCode) throws Parser.RegexException { - return Parser.matchGroup1(FUNCTION_NAME_PATTERN, playerJsCode); + String functionName = Parser.matchGroup1(FUNCTION_NAME_PATTERN, playerJsCode); + int arrayStartBrace = functionName.indexOf("["); + + if (arrayStartBrace > 0) { + String arrayVarName = functionName.substring(0, arrayStartBrace); + String order = functionName.substring(arrayStartBrace+1, functionName.indexOf("]")); + int arrayNum = Integer.parseInt(order); + Pattern ARRAY_PATTERN = Pattern.compile(String.format("var %s=\\[(.+?)\\];", arrayVarName)); + String arrayStr = Parser.matchGroup1(ARRAY_PATTERN, playerJsCode); + String names[] = arrayStr.split(","); + functionName = names[arrayNum]; + } + return functionName; } @Nonnull