Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public final class YoutubeThrottlingDecrypter {
private static final String DECRYPT_FUNCTION_BODY_REGEX =
"=\\s*function([\\S\\s]*?\\}\\s*return [\\w$]+?\\.join\\(\"\"\\)\\s*\\};)";

private static final String DECRYPT_FUNCTION_ARRAY_OBJECT_TYPE_DECLARATION_REGEX = "var ";
private static final String FUNCTION_NAMES_IN_DECRYPT_ARRAY_REGEX = "\\s*=\\s*\\[(.+?)][;,]";

private static final Map<String, String> N_PARAMS_CACHE = new HashMap<>();
private static String decryptFunction;
private static String decryptFunctionName;
Expand Down Expand Up @@ -117,7 +120,8 @@ private static String parseDecodeFunctionName(final String playerJsCode)

final int arrayNum = Integer.parseInt(matcher.group(2));
final Pattern arrayPattern = Pattern.compile(
"var " + Pattern.quote(functionName) + "\\s*=\\s*\\[(.+?)];");
DECRYPT_FUNCTION_ARRAY_OBJECT_TYPE_DECLARATION_REGEX + Pattern.quote(functionName)
+ FUNCTION_NAMES_IN_DECRYPT_ARRAY_REGEX);
final String arrayStr = Parser.matchGroup1(arrayPattern, playerJsCode);
final String[] names = arrayStr.split(",");
return names[arrayNum];
Expand Down