mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-27 23:40:36 +05:30
speed up finding decrypt function
This commit is contained in:
parent
5eac266a16
commit
dd61d66cf5
@ -708,15 +708,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String playerCode = downloader.download(playerUrl);
|
final String playerCode = downloader.download(playerUrl);
|
||||||
|
final String decryptionFunctionName = getDecryptionFuncName(playerCode);
|
||||||
|
|
||||||
final String decryptionFunctionName;
|
|
||||||
if (Parser.isMatch(DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX, playerCode)) {
|
|
||||||
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX, playerCode);
|
|
||||||
} else if (Parser.isMatch(DECRYPTION_AKAMAIZED_STRING_REGEX, playerCode)) {
|
|
||||||
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_AKAMAIZED_STRING_REGEX, playerCode);
|
|
||||||
} else {
|
|
||||||
decryptionFunctionName = Parser.matchGroup1(DECYRYPTION_SIGNATURE_FUNCTION_REGEX, playerCode);
|
|
||||||
}
|
|
||||||
final String functionPattern = "("
|
final String functionPattern = "("
|
||||||
+ decryptionFunctionName.replace("$", "\\$")
|
+ decryptionFunctionName.replace("$", "\\$")
|
||||||
+ "=function\\([a-zA-Z0-9_]+\\)\\{.+?\\})";
|
+ "=function\\([a-zA-Z0-9_]+\\)\\{.+?\\})";
|
||||||
@ -757,6 +750,27 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
return result == null ? "" : result.toString();
|
return result == null ? "" : result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDecryptionFuncName(String playerCode) throws DecryptException {
|
||||||
|
String decryptionFunctionName;
|
||||||
|
// Cascading things in catch is ugly, but its faster than running a match before getting the actual name
|
||||||
|
// to se if the function can actually be found with the given regex.
|
||||||
|
// However if this cascading should propably be cleaned up somehow as it looks a bit weird.
|
||||||
|
try {
|
||||||
|
decryptionFunctionName = Parser.matchGroup1(DECYRYPTION_SIGNATURE_FUNCTION_REGEX, playerCode);
|
||||||
|
} catch (Parser.RegexException re) {
|
||||||
|
try {
|
||||||
|
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX, playerCode);
|
||||||
|
} catch (Parser.RegexException re2) {
|
||||||
|
try {
|
||||||
|
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX, playerCode);
|
||||||
|
} catch (Parser.RegexException re3) {
|
||||||
|
throw new DecryptException("Could not find decrypt function with any of the given patterns.", re);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return decryptionFunctionName;
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private List<SubtitlesInfo> getAvailableSubtitlesInfo() throws SubtitlesException {
|
private List<SubtitlesInfo> getAvailableSubtitlesInfo() throws SubtitlesException {
|
||||||
// If the video is age restricted getPlayerConfig will fail
|
// If the video is age restricted getPlayerConfig will fail
|
||||||
|
Loading…
x
Reference in New Issue
Block a user