Skip to content

Commit 5306f7a

Browse files
committed
Improve code style
1 parent 38e9da8 commit 5306f7a

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,17 @@ public YoutubeThrottlingDecrypter() throws ParsingException {
6767
private String parseDecodeFunctionName(final String playerJsCode)
6868
throws Parser.RegexException {
6969
String functionName = Parser.matchGroup1(FUNCTION_NAME_PATTERN, playerJsCode);
70-
int arrayStartBrace = functionName.indexOf("[");
70+
final int arrayStartBrace = functionName.indexOf("[");
7171

7272
if (arrayStartBrace > 0) {
73-
String arrayVarName = functionName.substring(0, arrayStartBrace);
74-
String order = functionName.substring(arrayStartBrace+1, functionName.indexOf("]"));
75-
int arrayNum = Integer.parseInt(order);
76-
Pattern ARRAY_PATTERN = Pattern.compile(String.format("var %s=\\[(.+?)\\];", arrayVarName));
77-
String arrayStr = Parser.matchGroup1(ARRAY_PATTERN, playerJsCode);
78-
String names[] = arrayStr.split(",");
73+
final String arrayVarName = functionName.substring(0, arrayStartBrace);
74+
final String order = functionName.substring(
75+
arrayStartBrace + 1, functionName.indexOf("]"));
76+
final int arrayNum = Integer.parseInt(order);
77+
final Pattern arrayPattern = Pattern.compile(
78+
String.format("var %s=\\[(.+?)\\];", arrayVarName));
79+
final String arrayStr = Parser.matchGroup1(arrayPattern, playerJsCode);
80+
final String[] names = arrayStr.split(",");
7981
functionName = names[arrayNum];
8082
}
8183
return functionName;
@@ -99,15 +101,15 @@ private String parseWithParenthesisMatching(final String playerJsCode, final Str
99101

100102
@Nonnull
101103
private String parseWithRegex(final String playerJsCode, final String functionName) throws Parser.RegexException {
102-
Pattern functionPattern = Pattern.compile(functionName + "=function(.*?}};)\n",
104+
final Pattern functionPattern = Pattern.compile(functionName + "=function(.*?}};)\n",
103105
Pattern.DOTALL);
104106
return "function " + functionName + Parser.matchGroup1(functionPattern, playerJsCode);
105107
}
106108

107109
public String apply(final String url) throws Parser.RegexException {
108110
if (containsNParam(url)) {
109-
String oldNParam = parseNParam(url);
110-
String newNParam = decryptNParam(oldNParam);
111+
final String oldNParam = parseNParam(url);
112+
final String newNParam = decryptNParam(oldNParam);
111113
return replaceNParam(url, oldNParam, newNParam);
112114
} else {
113115
return url;

0 commit comments

Comments
 (0)