Improve getDescriptionFuncName by removing catches and adding a loop
This commit is contained in:
parent
9b45c61103
commit
bce87f3d01
|
@ -868,24 +868,21 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDecryptionFuncName(String playerCode) throws DecryptException {
|
private String getDecryptionFuncName(String playerCode) throws DecryptException {
|
||||||
String decryptionFunctionName;
|
String[] decryptionFuncNameRegexes = {
|
||||||
// Cascading things in catch is ugly, but its faster than running a match before getting the actual name
|
DECRYPTION_SIGNATURE_FUNCTION_REGEX,
|
||||||
// to se if the function can actually be found with the given regex.
|
DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX,
|
||||||
// However if this cascading should probably be cleaned up somehow as it looks a bit weird.
|
DECRYPTION_AKAMAIZED_STRING_REGEX
|
||||||
try {
|
};
|
||||||
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_SIGNATURE_FUNCTION_REGEX, playerCode);
|
Parser.RegexException exception = null;
|
||||||
} catch (Parser.RegexException re) {
|
for (String regex : decryptionFuncNameRegexes) {
|
||||||
try {
|
try {
|
||||||
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX, playerCode);
|
return Parser.matchGroup1(regex, playerCode);
|
||||||
} catch (Parser.RegexException re2) {
|
} catch (Parser.RegexException re) {
|
||||||
try {
|
if (exception == null)
|
||||||
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_AKAMAIZED_STRING_REGEX, playerCode);
|
exception = re;
|
||||||
} catch (Parser.RegexException re3) {
|
|
||||||
throw new DecryptException("Could not find decrypt function with any of the given patterns.", re);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return decryptionFunctionName;
|
throw new DecryptException("Could not find decrypt function with any of the given patterns.", exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|
Loading…
Reference in New Issue