From 9aa8c4ad4fc6ac95dcc69ed64b08407e08b208a5 Mon Sep 17 00:00:00 2001 From: fuzhengyin <89236842+fuzhengyin@users.noreply.github.com> Date: Tue, 1 Feb 2022 15:51:16 +0800 Subject: [PATCH] test --- .../youtube/YoutubeThrottlingDecrypter.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 3ba8e2dadc..4da73bf8d0 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 @@ -36,8 +36,7 @@ public class YoutubeThrottlingDecrypter { private static final Pattern N_PARAM_PATTERN = Pattern.compile("[&?]n=([^&]+)"); private static final Pattern FUNCTION_NAME_PATTERN = Pattern.compile( - "b=a\\.get\\(\"n\"\\)\\)&&\\(b=(\\w+)\\(b\\),a\\.set\\(\"n\",b\\)"); - + "b=a\\.get\\(\"n\"\\)\\)&&\\(b=(.+?)\\(b\\),a\\.set\\(\"n\",b\\)"); private static final Map nParams = new HashMap<>(); private final String functionName; @@ -66,7 +65,18 @@ public YoutubeThrottlingDecrypter() throws ParsingException { private String parseDecodeFunctionName(final String playerJsCode) throws Parser.RegexException { - return Parser.matchGroup1(FUNCTION_NAME_PATTERN, playerJsCode); + String functionName = Parser.matchGroup1(FUNCTION_NAME_PATTERN, playerJsCode); + if (functionName.contains("[")) { + int arrayStartBrace = functionName.indexOf("["); + 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 arrayString = Parser.matchGroup1(ARRAY_PATTERN, playerJsCode); + String names[] = arrayString.split(","); + functionName = names[arrayNum]; + } + return functionName; } @Nonnull