Merge pull request #329 from wb9688/decryption-regexes

Add more decryption function regexes
This commit is contained in:
Tobias Groza 2020-05-29 10:10:50 +02:00 committed by GitHub
commit cf18cdb2f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 17 deletions

View File

@ -583,14 +583,21 @@ public class YoutubeStreamExtractor extends StreamExtractor {
private static final String HTTPS = "https:"; private static final String HTTPS = "https:";
private static final String DECRYPTION_FUNC_NAME = "decrypt"; private static final String DECRYPTION_FUNC_NAME = "decrypt";
private final static String DECRYPTION_SIGNATURE_FUNCTION_REGEX = private final static String[] REGEXES = {
"([\\w$]+)\\s*=\\s*function\\((\\w+)\\)\\{\\s*\\2=\\s*\\2\\.split\\(\"\"\\)\\s*;"; "\\b[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*encodeURIComponent\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
private final static String DECRYPTION_SIGNATURE_FUNCTION_REGEX_2 = "\\b[a-zA-Z0-9]+\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*encodeURIComponent\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
"\\b([\\w$]{2})\\s*=\\s*function\\((\\w+)\\)\\{\\s*\\2=\\s*\\2\\.split\\(\"\"\\)\\s*;"; "\\b([a-zA-Z0-9$]{2})\\s*=\\s*function\\(\\s*a\\s*\\)\\s*\\{\\s*a\\s*=\\s*a\\.split\\(\\s*\"\"\\s*\\)",
private final static String DECRYPTION_AKAMAIZED_STRING_REGEX = "([a-zA-Z0-9$]+)\\s*=\\s*function\\(\\s*a\\s*\\)\\s*\\{\\s*a\\s*=\\s*a\\.split\\(\\s*\"\"\\s*\\)",
"yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*c\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(:encodeURIComponent\\s*\\()([a-zA-Z0-9$]+)\\("; // Obsolete patterns
private final static String DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX = "[\"']signature[\"']\\s*,\\s*([a-zA-Z0-9$]+)\\(",
"\\bc\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(:encodeURIComponent\\s*\\()([a-zA-Z0-9$]+)\\("; "\\.sig\\|\\|([a-zA-Z0-9$]+)\\(",
"yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*(?:encodeURIComponent\\s*\\()?\\s*([a-zA-Z0-9$]+)\\(",
"\\b[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*([a-zA-Z0-9$]+)\\(",
"\\b[a-zA-Z0-9]+\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*([a-zA-Z0-9$]+)\\(",
"\\bc\\s*&&\\s*a\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
"\\bc\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
"\\bc\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\("
};
private volatile String decryptionCode = ""; private volatile String decryptionCode = "";
@ -767,20 +774,15 @@ public class YoutubeStreamExtractor extends StreamExtractor {
return result == null ? "" : result.toString(); return result == null ? "" : result.toString();
} }
private String getDecryptionFuncName(String playerCode) throws DecryptException { private String getDecryptionFuncName(final String playerCode) throws DecryptException {
String[] decryptionFuncNameRegexes = {
DECRYPTION_SIGNATURE_FUNCTION_REGEX_2,
DECRYPTION_SIGNATURE_FUNCTION_REGEX,
DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX,
DECRYPTION_AKAMAIZED_STRING_REGEX
};
Parser.RegexException exception = null; Parser.RegexException exception = null;
for (String regex : decryptionFuncNameRegexes) { for (final String regex : REGEXES) {
try { try {
return Parser.matchGroup1(regex, playerCode); return Parser.matchGroup1(regex, playerCode);
} catch (Parser.RegexException re) { } catch (Parser.RegexException re) {
if (exception == null) if (exception == null) {
exception = re; exception = re;
}
} }
} }
throw new DecryptException("Could not find decrypt function with any of the given patterns.", exception); throw new DecryptException("Could not find decrypt function with any of the given patterns.", exception);