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
|
||||||
|
};
|
||||||
|
Parser.RegexException exception = null;
|
||||||
|
for (String regex : decryptionFuncNameRegexes) {
|
||||||
try {
|
try {
|
||||||
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_SIGNATURE_FUNCTION_REGEX, playerCode);
|
return Parser.matchGroup1(regex, playerCode);
|
||||||
} catch (Parser.RegexException re) {
|
} catch (Parser.RegexException re) {
|
||||||
try {
|
if (exception == null)
|
||||||
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX, playerCode);
|
exception = re;
|
||||||
} catch (Parser.RegexException re2) {
|
|
||||||
try {
|
|
||||||
decryptionFunctionName = Parser.matchGroup1(DECRYPTION_AKAMAIZED_STRING_REGEX, playerCode);
|
|
||||||
} catch (Parser.RegexException re3) {
|
|
||||||
throw new DecryptException("Could not find decrypt function with any of the given patterns.", re);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
throw new DecryptException("Could not find decrypt function with any of the given patterns.", exception);
|
||||||
return decryptionFunctionName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|
Loading…
Reference in New Issue