@@ -37,9 +37,12 @@ final class YoutubeSignatureUtils {
3737 private static final String DEOBF_FUNC_REGEX_START = "(" ;
3838 private static final String DEOBF_FUNC_REGEX_END = "=function\\ ([a-zA-Z0-9_]+\\ )\\ {.+?\\ })" ;
3939
40- private static final String SIG_DEOBF_HELPER_OBJ_NAME_REGEX = ";([A-Za-z0-9_\\ $]{2,})\\ ...\\ (" ;
40+ // CHECKSTYLE:OFF
41+ private static final String SIG_DEOBF_GLOBAL_ARRAY_REGEX = "(var [A-Z]='.*'.split\\ (\" ;\" \\ ))" ;
42+ private static final String SIG_DEOBF_HELPER_OBJ_NAME_REGEX = ";([A-Za-z0-9_\\ $]{2,})\\ [.." ;
4143 private static final String SIG_DEOBF_HELPER_OBJ_REGEX_START = "(var " ;
4244 private static final String SIG_DEOBF_HELPER_OBJ_REGEX_END = "=\\ {(?>.|\\ n)+?\\ }\\ };)" ;
45+ // CHECKSTYLE:ON
4346
4447 private YoutubeSignatureUtils () {
4548 }
@@ -88,6 +91,9 @@ static String getDeobfuscationCode(@Nonnull final String javaScriptPlayerCode)
8891 // Assert the extracted deobfuscation function is valid
8992 JavaScript .compileOrThrow (deobfuscationFunction );
9093
94+ final String globalVar =
95+ Parser .matchGroup1 (SIG_DEOBF_GLOBAL_ARRAY_REGEX , javaScriptPlayerCode );
96+
9197 final String helperObjectName =
9298 Parser .matchGroup1 (SIG_DEOBF_HELPER_OBJ_NAME_REGEX , deobfuscationFunction );
9399
@@ -98,7 +104,7 @@ static String getDeobfuscationCode(@Nonnull final String javaScriptPlayerCode)
98104 + deobfuscationFunctionName
99105 + "(a);}" ;
100106
101- return helperObject + deobfuscationFunction + ";" + callerFunction ;
107+ return globalVar + ";" + helperObject + deobfuscationFunction + ";" + callerFunction ;
102108 } catch (final Exception e ) {
103109 throw new ParsingException ("Could not parse deobfuscation function" , e );
104110 }
0 commit comments