Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhengyin committed Feb 1, 2022
1 parent a3e26b8 commit 9aa8c4a
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> nParams = new HashMap<>();

private final String functionName;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9aa8c4a

Please sign in to comment.