Improve code style
This commit is contained in:
parent
38e9da8d44
commit
5306f7a988
|
@ -67,15 +67,17 @@ public class YoutubeThrottlingDecrypter {
|
||||||
private String parseDecodeFunctionName(final String playerJsCode)
|
private String parseDecodeFunctionName(final String playerJsCode)
|
||||||
throws Parser.RegexException {
|
throws Parser.RegexException {
|
||||||
String functionName = Parser.matchGroup1(FUNCTION_NAME_PATTERN, playerJsCode);
|
String functionName = Parser.matchGroup1(FUNCTION_NAME_PATTERN, playerJsCode);
|
||||||
int arrayStartBrace = functionName.indexOf("[");
|
final int arrayStartBrace = functionName.indexOf("[");
|
||||||
|
|
||||||
if (arrayStartBrace > 0) {
|
if (arrayStartBrace > 0) {
|
||||||
String arrayVarName = functionName.substring(0, arrayStartBrace);
|
final String arrayVarName = functionName.substring(0, arrayStartBrace);
|
||||||
String order = functionName.substring(arrayStartBrace+1, functionName.indexOf("]"));
|
final String order = functionName.substring(
|
||||||
int arrayNum = Integer.parseInt(order);
|
arrayStartBrace + 1, functionName.indexOf("]"));
|
||||||
Pattern ARRAY_PATTERN = Pattern.compile(String.format("var %s=\\[(.+?)\\];", arrayVarName));
|
final int arrayNum = Integer.parseInt(order);
|
||||||
String arrayStr = Parser.matchGroup1(ARRAY_PATTERN, playerJsCode);
|
final Pattern arrayPattern = Pattern.compile(
|
||||||
String names[] = arrayStr.split(",");
|
String.format("var %s=\\[(.+?)\\];", arrayVarName));
|
||||||
|
final String arrayStr = Parser.matchGroup1(arrayPattern, playerJsCode);
|
||||||
|
final String[] names = arrayStr.split(",");
|
||||||
functionName = names[arrayNum];
|
functionName = names[arrayNum];
|
||||||
}
|
}
|
||||||
return functionName;
|
return functionName;
|
||||||
|
@ -99,15 +101,15 @@ public class YoutubeThrottlingDecrypter {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private String parseWithRegex(final String playerJsCode, final String functionName) throws Parser.RegexException {
|
private String parseWithRegex(final String playerJsCode, final String functionName) throws Parser.RegexException {
|
||||||
Pattern functionPattern = Pattern.compile(functionName + "=function(.*?}};)\n",
|
final Pattern functionPattern = Pattern.compile(functionName + "=function(.*?}};)\n",
|
||||||
Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
return "function " + functionName + Parser.matchGroup1(functionPattern, playerJsCode);
|
return "function " + functionName + Parser.matchGroup1(functionPattern, playerJsCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String apply(final String url) throws Parser.RegexException {
|
public String apply(final String url) throws Parser.RegexException {
|
||||||
if (containsNParam(url)) {
|
if (containsNParam(url)) {
|
||||||
String oldNParam = parseNParam(url);
|
final String oldNParam = parseNParam(url);
|
||||||
String newNParam = decryptNParam(oldNParam);
|
final String newNParam = decryptNParam(oldNParam);
|
||||||
return replaceNParam(url, oldNParam, newNParam);
|
return replaceNParam(url, oldNParam, newNParam);
|
||||||
} else {
|
} else {
|
||||||
return url;
|
return url;
|
||||||
|
|
Loading…
Reference in New Issue